   Problems with inline class methods in VC++
  I keep running into problems with VC++ 6 making class methods inlined. I don''t want to declare them in the header file but use the inline tags and put the function body in the .cpp file. However I''ve tried different combinations of where I put the inline keyword (also using __forceinline) without success.If for example my .h file has:class foo{private:int var;void Set(int v);};  And my .cpp file hasvoid foo::Set(int v){var=v;}  What should I do to get the greatest chance of inlining? I keep getting errors when I try. 
  i think you just define them in the header file as such: class foo{private:   int var;   inline void Set(int v) { var=v; }}; ;  Let me ask you a question: how do you expect the compiler to inline a function, if it doesn''t have access to the function''s implementation? ;quote:Original post by Palidine  i think you just define them in the header file as such: class foo{private:   int var;   inline void Set(int v) { var=v; }};  Correct, but as far as I recall, methods implemented inside the class body are automatically declared as inlines.cya,Drag0n   -----------------------------"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning..." -- Rich CookMy future web presence: Dave''s Programming Resources;  If you have .NET (possibly only in .NET2003) you can enable LTCG (Link Time Code Generation).  It might work... I wouldn''t bet on it.DirectX often uses .inl files, like below.  It keeps the code out of the cpp, but is technically a header... even though only the .h files includes this other .inl header file.--blah.h--#ifndef inc_blah_h_#define inc_blah_h_class blah{  inline void blahfunc();};#include "blah.inl"#endif--blah.inl--void blah::blahfunc(){  } ;  I already said I don''t want the function body in the class definition in the header. I want to have the function code in the cpp file along with all non-inline functions. Surely I can tell the compiler a method is inline in the class definition, then actually put the code elsewhere and the compiler remember this?Otherwise the inline keyword is virtually useless. ;  Have you tried inlining the function definintion, rather than placing the tag in your class definition. I recall having a problem with this a while ago. There are issues with inlining member functions. ;As I said!.   [edited by - mathematix on February 3, 2004 4:38:15 AM];  But in that link they also say you can have the body elsewhere than in the class definition if you use the inline keyword explicitly - going to try that combination now... ;  ...nope, don''t work. The link to MSDN says you can just add the inline keyword at the start of your function declaration ievoid myclass::func(){...}  becomesinline void myclass::func(){...}  When I do this for one member function, I get linker errors that other   member functions are now unresolved externals - not all of them just a few. How is it possible that changing one method screws up the others?