Hello,

On Sat, 1 Oct 2022, Liam Wilson wrote:

Note __attribute__((constructor)) has been stripped off bar and not foo.

Yep, that's the glibc headers defining __attribute__ away ...

Digging a bit further, it seems to be due to sys/cdefs.h (which is
included by string.h and many other standard headers). In sys/cdefs.h
I found this:

... as you found out.

Is there a work around for this issue? I can define __GNUC__ but presumably that may cause other issues?

The work-around is to use the other form of attribute: __attribute(foo)
(note the missing suffix of '__'). That's still in the implementation namespace and not defined away by glibc.

The other work-around would be to '#undef __attribute__' after all glibc headers are included. As <sys/cdefs.h> (on glibc!) also has header guards you might also get away with this, as first directives in the .c files:

  #include <sys/cdefs.h>
  #undef __attribute__

as the following includes, even if they include <sys/cdefs.h> again, won't parse its content again. As TCC ignores unknown attributes that should work fine for the decls in the glibc headers as well.


Ciao,
Michael.

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to