On Thu, 5 Apr 2018, ra...@airmail.cc wrote:
I made this test program which I expect to print all 0's, but it
I noticed that after tcc -E the attributes have all disappeared.
Any idea what is stopping this from working? the attribute is documented
and code gen seems to respect TOK_ALIGNED. I wasn't able to understand
how it vanishes by looking at tccpp.c so advice would be welcome.
Yes, you stumbled over an artifact of the glibc standard headers. If used
with a compiler that doesn't claim to be GCC (e.g. with TCC), you'll hit
this snippet in /usr/include/sys/cdefs.h:
#if !defined __GNUC__ || __GNUC__ < 2
# define __attribute__(xyz) /* Ignore */
Et voila, all your __attribute__ uses are defined away. Luckily the
standard headers don't do the same with either __attribute (without the
trailing double-underscore), so you can use that in your code.
Alternatively you can do an '#undef __attribute__' after all standard
headers are included. None of that helps for the __attribute__ uses in
the standard headers themself (although they are optional anyway), for
that you'd have to define __GNUC__ to 2 at least. But that has further
ramifications as TCC is somewhat but not completely compatible with
several GNU extensions.
Tinycc-devel mailing list