Inlining problem

Robert Schweikert rjschwei@mindspring.com
Wed Jan 3 18:42:00 GMT 2001


Attached is a .i file that demonstrates a problem with inlining in
gcc-2.95.2. I do not understand why the inlining is not working, as
similar use of inlining in other classes works.

Here is the problem


-> g++ -c modSectLay.i

-> nm -Bg modSectLay.o | grep DeclareMatVar

         U DeclareMatVar__14MatPointLayoutRC13MatPointVarIDT1

         U DeclareMatVar__14MatPointLayoutRC13MatPointVarIDi

-> c++filt DeclareMatVar__14MatPointLayoutRC13MatPointVarIDT1

MatPointLayout::DeclareMatVar(MatPointVarID const &, MatPointVarID const &)

The method "DeclareMatVar(MatPointVarID const &, MatPointVarID const &)"
is declared as inline, and thus no symbol should be created when the
method is being called. This of course leads to link errors.

The declaration of "DeclareMatVar(MatPointVarID const &, MatPointVarID
const &)" is in line 2324 in the .i file, the implementation starts on
line 2759 and the call is in line 2826 of the .i file.

To work around this problem I made the method out of line. This didn't
cause any performance drop. However, I would like to understand why g++
is not inlining this function to let other programmers know what we need
to do to make inlining work consistently in our code on Linux.

Any help is appreciated.

Robert

--
Robert Schweikert                      MAY THE SOURCE BE WITH YOU
rjschwei@mindspring.com                         LINUX




More information about the Gcc mailing list