On 2018-04-06 20:13, Michael Matz wrote:
Hi,

On Thu, 5 Apr 2018, ra...@airmail.cc wrote:

I made this test program which I expect to print all 0's, but it doesn't.

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 */
#endif

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.


Ciao,
Michael.

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

Thank you very much for the info!

I tried modifying my test program to use __attribute instead, in that case the code line 3345: case TOK_ALIGNED2: is being executed which is good. but again the output is not zeros. Perhaps a.aligned is being ignored for functions during codegen.

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

Reply via email to