Paul Hansen <paul.hansen.name@xxxxxxxxx> writes: > I am trying to make a library that contains this class: > > class C { > void DefinedInBody(void) {} > void DeclaredInBody(void); > }; > void C::DeclaredInBody() {} > > I compile class C with > $ cc -O0 -fno-default-inline -c class.cpp -o class.o > > But the object file contains no sign of C::DefinedInBody(), only > C::DeclaredInBody() > $ nm -C class.o > ... > T C::DeclaredInBody() > > Afaics I am using the right compile options but DefinedInBody() is > still inline code. > > The manual has, in section Dialect Options#-fno-default-inline, this > puzzling sentence: Note that these functions will have linkage like > inline functions; they just won't be inlined by default. > I assume the -fno-default-inline flag can prevent linkage like inline > functions. If not, I don't understand the purpose of the flag. Unfortunately, the manual is simply wrong. The -fno-default-inline option is ignored. Even when it did exist, it never changed the linkage. All it did was change the inlining heuristics so that functions declared in class bodies were not actually inlined. It did not cause the functions to be emitted when they were not called, as you would like. They would only be emitted when they were called, as described at http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc/Vague-Linkage.html . Ian