-
January 9th, 2004, 11:24 PM
#1
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 10th, 2004, 12:41 AM
#2
Re: LNK2019 if inline fine if not
Originally posted by Improving
Do the inline functions have to be in the header file ?
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)
-
January 11th, 2004, 05:04 AM
#3
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, 05:59 AM
#4
Take a look at the following FAQ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|