This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[g++] __attribute__ ((constructor)) does not work
- To: gcc-bugs at gcc dot gnu dot org
- Subject: [g++] __attribute__ ((constructor)) does not work
- From: Samuel Landau <Samuel dot Landau at lip6 dot fr>
- Date: Tue, 21 Mar 2000 18:11:42 +0100
- Cc: Stephane Doncieux <Stephane dot Doncieux at lip6 dot fr>, Stephane Gourichon <Stephane dot Gourichon at lip6 dot fr>
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