January 9th, 2004, 10:24 PM
LNK2019 if inline fine if not
Subject basically sums it up. I have a class and the .h is code free and in the .cpp file for that class I use inline on the function definitions I want inlined. Main.cpp includes "myclass.h" and does some tests on the class. Everytime I call a function I have specified as inline I get a LNK2019 unresolved external. If I remove the inline specifier the code compiles and runs perfectly but not as quick as I'd like. So how do you keep .h code free and tell the compiler (msvc7) to inline the functions? Do the inline functions have to be in the header file ? I checked help files but they were useless only showing single-file code.
Hungarian notation is the bane of self documenting code.
Forget all fancy tricks with operator precedence. Code should be easily readable.
May the BOOST
be with you.
Good free E-Books
thanks to Bruce Eckel.
January 9th, 2004, 11:41 PM
Re: LNK2019 if inline fine if not
short answer, yes. the body of the inlined function has to be in the same scope as the place where it gets inlined. (when in doubt, check with the standard: 3.2.4. An inline function shall be defined in every translation unit in which it is used)
Originally posted by Improving
Do the inline functions have to be in the header file ?
January 11th, 2004, 04:04 AM
Definition of the inline functions need to be in the same file as the declaration of the class which contain the inline functions.
Alternatively, u can define these functions within the class declaration without using the keyword inline, serve the same purpose anyway.
January 11th, 2004, 04:59 AM
Take a look at the following FAQ...
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!