On Thu, Nov 15, 2001 at 04:43:58PM +0100, Aaron Ardiri wrote:
[Re enumeration constants and SYS_TRAP macros]
> actually.. this bug has been around for a while :) i believe it
> is actually a bug in the way prc-tools compiles :P
It is not a bug in prc-tools. Aaron, I wish you wouldn't post FUD like
this!
> old 0.5.0 prc-tools uses to handle enumarations.. but, the new
> stuff 2.0+ doesn't :)
Putting an enumeration constant in a SYS_TRAP-style macro has always
been undefined behaviour. The version of GCC in prc-tools 0.5.0 was
able to support this functionality, but the version (3.x) in future
prc-tools versions cannot. A reasonable implementation is simply not
possible. If it were possible, don't you think I would have done it
rather than cause all this trouble?!
> the simple solution was to use #defines'
> instead.. and, i remember john mentioning this at palmsource 2000
> in his "tools" presentation..
It seems that you weren't listening to my PalmSource talk very carefully.
For the benefit of others, and of SCL who often has difficulty believing
this too, I'll repeat it.
Historically, it was unspecified exactly what could be given to SYS_TRAP.
Expressions involving literal numbers and enumerations seemed to work.
What about other things that a C programmer would consider to be integer
constant expressions: sizeof expressions or (cast) floats? What about
C++ integral constant-expressions: const variables and const static data
members of classes, possibly inside several layers of namespace? What
about programs in other languages (e.g. asm) which might want to use
CoreTraps.h but don't know enough about C to decode an enumeration
constant or a sizeof expression, let along those C++ things?
Historically, there was a de facto understanding that enumeration
constants worked, but that is all it was. Most of those other kinds
of constant didn't work, and maybe complex expressions involving
enumeration constants wouldn't work. Nobody really knew, because it
was all unspecified.
So while at Palm I specified it [1], and in a way that is useful for
those other languages too:
after preprocessing, all expressions in SYS_TRAP-style macros
must be arithmetic expressions (namely ( ) + - * /) involving
only literal integer constants (i.e. sequences of digits)
(*plural* expressions because simple SYS_TRAPs are not all there is
to it. There are also selectorized traps, which, you may remember,
prc-tools 0.5.0 could not handle *at all*.)
This was useful for other miscellaneous tools, but especially for GCC:
The SYS_TRAP macro is handled very early in GCC. The version in 0.5.0
was able to decode an enumeration constant at that early stage (though
it was merely a lucky hack). Later, when namespaces were implemented in
G++, the relevant symbol table data structures were rearranged and it
became impractical to decode enumeration constants at that early stage
of compilation. At the moment (GCC 2.95.3), there is a *hideous*
problematic hack that sort of does it (so that the deprecated legacy
__systrap__ attribute still works with enumeration constants), but it's
unmaintainable and won't be kept.
> gotta always update the header files i get from people due to this
> (sony, printboy libs, gamepad driver) etc.. its a pain in the ass.
> when will it be fixed john? *g* it used to work a long time ago :P
I don't know when it will be fixed. I don't distribute Sony, printboy,
or gamepad SDKs. Perhaps you should contact their authors, and
encourage them to fix the invalid constructs in their SDKs. It is a
very simple fix to make.
Or, if this pains you so much, I invite you to rewrite GCC so that the
values of enumeration constants are available early in the compiler. It
will be hard to get right when the identifier appears in multiple scopes
(e.g. namespaces), but I eagerly await your patches.
BTW in English, even in Australia, it's polite to capitalise a person's
name.
John
[1] I confess I was very busy and didn't pay enough attention to getting
this promulgated widely and documented at the time. I have since been
trying to rectify this, and I hope Palm will help do that.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/