Archived

This topic is now archived and is closed to further replies.

y2kiah

MS VC++ 6.0 inline issues

Recommended Posts

Whenever I inline a function that is called in a source file other than the one in which the function is defined, I get an error in the linker phase. The error is unresolved external symbol for the function call. Is this just a VC++ 6.0 issue? If so are there any fixes to the compiler to allow inlining? I have the latest service pack installed I know VC++ 6.0 supposedly ignores the inline keyword, but the code may be compiled with something else in the future. Also, __inline keyword in VC++ 6.0 would force an inline? I haven''t tried it but this may have the same issue as above. Thanks

Share this post


Link to post
Share on other sites
Most compilers don''t support inline functions being called from different compilation units. VC++ 6.0 is no exception. (VC++ .NET is an exception.) You''ll have to declare the function inline in the header.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
__forceinline should force the compiler to inline the function however Visual Studio 6/.Net 2002/.Net 2003 ignore this and inline only if the compiler thinks it is effective to inline this function.
inline = _inline = __inline.

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
quote:
Original post by y2kiah
they are member functions for various classes. all are declared inline in both the header and source.



I can''t tell if it ever got figured out on this thread, but an inline function must be defined in every translation unit from which it''s called, i.e. the entire body of the function has to be in the header file (or otherwise defined the exact same way in each cpp file.)

quote:

So it must be a standard issue, I didn''t realize. I don''t remember ever having the problem when I was compiling with DJGPP.



GCC -- upon which DJGPP is based -- also emits an out-of-line version of inline functions when necessary. So in DJGPP you really only had the code inlined in translation units that could actually see the definition, otherwise they used standard linkage.

Share this post


Link to post
Share on other sites