[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] preprocessor makes attributes disappear

From: rain1
Subject: Re: [Tinycc-devel] preprocessor makes attributes disappear
Date: Fri, 06 Apr 2018 20:58:07 +0100
User-agent: Roundcube Webmail/1.3.3

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

On Thu, 5 Apr 2018, address@hidden 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 */

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

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]