help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Forcing instantiation of static class functions


From: Mike Harrold
Subject: Forcing instantiation of static class functions
Date: Sat, 05 May 2007 17:40:43 -0000

Hi all,

I have a class that looks like this:

class X
{
public:

  static void
  foo()
  {
    do_something();
  }
};

Of course, it's more complex than that, but the issue is what is
important.  My build process generates header files from class
files, so there's a header file for this (X.hh) that allows other
units to call X::foo.

Since moving to gcc-4.1 (from gcc.3.4) I notice that gcc is no
longer emitting the code for foo() inside this unit. The only way
that I have (so far) discovered to force this is to use the
__attribute__ ((used)) functionality. I __really__ don't want to
have to do that, as there are several hundred (if not thousands)
of functions affected by this compiler change.

Is there a command line switch that changes this behaviour? (And
not -fkeep-inline as it keeps all inline functions in the module,
which in many cases is several hundred per unit because of all the
included header files!)

Thanks!

Regards,

/Mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]