Hello,

This suggestion is obviously about typdefs and discusses a *theoretical* implementation, well a few of them. Anyway please do read this though. I'm really sorry for the poor structure, my hands are really cold and I'm quite tired. I understand that this issue has been discussed A LOT and there are ways around the limitation, I suspect what I write is nothing new, I don't claim to be the first ever.

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.

It'd break something if put before "struct" obviously, because struct need not occur at the beginning of a statement, I can't see the typdef thing being a problem, it never occurs anywhere else, and this construct need not be valid anywhere else.


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? Use this to create a definition for hard (as "hard") if and only if GCC is the compiler, else define "hard" as an empty definition (nothing), this way any other compilers wont even see the "hard" before a typedef. If GCC recognises half without a macro this means those using just GCC would be fine but they need only put a constant in a header file.

I am not sure how the preprocessor would handle a keyword named constant ("#define hard hard" is what I'm thinking? Wish I could try it now) but I am certain "#define HARD hard" would work, while ugly this does make compatibility easy.

Pros:
The joy of many.

Alec
Sorry again for the awful new-line structure, I'm tired and my fingers are numb.

Reply via email to