[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] preprocessor makes attributes disappear
From: |
Michael Matz |
Subject: |
Re: [Tinycc-devel] preprocessor makes attributes disappear |
Date: |
Fri, 6 Apr 2018 21:13:43 +0200 (CEST) |
User-agent: |
Alpine 2.20 (LSU 67 2015-01-07) |
Hi,
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 */
#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.