This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[g++] __attribute__ ((constructor)) does not work



hello
using g++ on the last Mandrake Linux distro (EGCS 2.95.2), g++ does not accept __attribute__ 
((constructor)) directive, while gcc does.

we also tried on http://www.codesourcery.com/gcc-compile.html
try with this code please (using c++):
$ cat test.cpp 
#include <iostream.h>

void initialization (void) __attribute__ ((constructor));

void initialization(void)
{
cout << "initialisation" << endl;
};

int main()
{
cout << "fin" << endl;
exit(0);
};
$ ./gcc-compile.py 
fin

while with this code (using c):
$ cat test.c
#include <stdio.h>

void initialization (void) __attribute__ ((constructor));

void initialization(void)
{
 printf("initialisation\n");
  fflush(stdout);
  };

  int main()
  {
   printf("fin\n");
    fflush(stdout);
    exit(0);
    };
$ ./gcc-compile.py
initialisation
fin
$ 

it worked.

we also tried using 'extern "C"{...}' directive for the C++ code, but it didn't work any better.
we saw that there was a bug report and a patch to apply in the bug archive mailing-list, this was
about a year ago (watch for a post of Jason Merrill <jason@cygnus.com>), but our version of egcs
and the one we could use on http://www.codesourcery.com/ are _of course_ much more recent than that.
what do you suggest/plan to do?

Thanks in advance,
    
-- 
Samuel Landau
PhD student in Computer Science/Artificial Intelligence

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]