Trying to put inline functions in external file within project, and getting below errors.
If I remove "__forceinline", then all is well.
If I have the inline function in main cpp file and not in header, it is fine also.
Is there a procedure to deal with this?

file.h

__forceinline __int64 Parse(const unsigned char *);

file.cpp

__forceinline __int64 Parse(const unsigned char * parsearray){
//nothing special
return 0;
}

error LNK2001: unresolved external symbol "__int64 __cdecl Parse(const unsigned char *)"
fatal error LNK1120: 1 unresolved externals

(edit)
I am aware that __forceinline does not mean the compiler (vs2010) will inline it.

Edited 3 Years Ago by Suzie999

inline functions can't be declared in a *.cpp file and expect it to be inlined in other *.cpp files. Put the entire code in the file.h header file so that the compiler can duplicate the code each time the function is called. This is consistent with the use of _inline for c++ class methods, where you write the entire function in the header file.

Edited 3 Years Ago by Ancient Dragon

For the compiler to be able to inline a function, it must see its definition (implementation). This means you cannot do the classic "declaration in header" / "definition in cpp file" paradigm. The definition must be in the header file. Marking the function as inline or __forceinline tells the compiler that this is what you will do, thus making the functions candidates for inlining.

Thanks for your time and explanation.
Of course it is sage advice and works as expected.

This question has already been answered. Start a new discussion instead.