This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: hard typdef - proposal - I know it's not in the standard
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Alec Teal <a dot teal at warwick dot ac dot uk>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Wed, 23 Jan 2013 08:55:42 +0000
- Subject: Re: hard typdef - proposal - I know it's not in the standard
- References: <50FF88D2.8080604@warwick.ac.uk>
On 23 January 2013 06:53, Alec Teal wrote:
> Why not:
>
> make an "optional keyword", "hard", have a meaning if before "typedef", I
> suggest tokenising "hard" as a normal token (however it is processed now why
> change it? I am not sure on GCCs exact grammar for c languages) but if AND
> ONLY if it is before a "typdef" treat it differently, as far as I know a
> typedef can only occur at the beginning of a statement so this should mean
> it doesn't break anything.
Like other specifiers such as const and static, typedef doesn't have
to come first, i.e. this is legal, if unconventional:
typedef int hard;
hard typedef Int;
I think Basile's suggestion to implement it as an attribute is a
better idea, it makes it clearer it's something non-standard and
compiler-specific, and the grammar already contains attributes in
declarations.
> Problems:
>
> 1)Not all compilers would be happy with this.
> Fix:
> I'm sure gcc must define something for the preprocessor that'll exist if and
> only if GCC is the compiler?
Nope, Compilers that claim GCC compatibility also define __GNUC__, and
as has been discussed before on this list, if we added __REALLY_GCC__
then other compilers would just add that too.