Inlining in g++

Joris van der Hoeven TeXmacs@math.u-psud.fr
Sat Dec 11 07:18:00 GMT 1999


Dear collegue,

Is there some way for me to decide that precisely those
functions which I declared inline are inlined and no others?
When compiling a C++ program using optimization, I have    
the following problems:    
  - The generated code is not equivalent; my program produces
    a segmentation fault, while the unoptimized code does not.
  - Not all functions which have been declared inline are 
    actually inlined.
  - Some functions which I did not declare inline are inlined.
Because of the fact that optimized code is much longer and
crashes, I would like to have full control over the inlining
process. Ideally speaking, I would appreciate non optimized
compilation with all functions declared 'extern inline'
being inlined.

If there is no way to satisfy my request, maybe you can
suggest another solution for the following problem.
I have several very elementary data structures like
'array', 'list', 'hashtable', etc... All these classes
export a function 'N', which determines the number of
elements in the array, list, etc... I declared this
function inline for most structures, since it really
corresponds to a macro definition pointing to some member.
However, for the reasons explained above, the inlining
mechanism does not correctly handle this situation.
Might there be another way out, like defining a macro
which first tests the type of the argument and
then expands as a function of the type (very dirty,
but this would be satisfactory).

Yours,

Joris van der Hoeven


More information about the Gcc-help mailing list