Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.
Bill Caroselli <qtps@earthlink.net> wrote:
Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.
I don’t know – but gcc-xxx has a -fsigned-char and -funsigned-char
option.
Might you be able to force the builds to match?
-David
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.
Bill Caroselli <qtps@earthlink.net> wrote:
Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.
if you are compiling with gcc (as opposed to qcc) then it will add
-D__CHAR_UNSIGNED__ if you pass -funsigned-char
qcc isn’t quite that smart, alas. :v(
If signedness is important, then it should generally be explicitly
used in the typedef…
Bill Caroselli <qtps@earthlink.net> wrote:
Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.
#if CHAR_MIN == 0
Colin Burgess <cburgess@qnx.com> wrote:
Bill Caroselli <> qtps@earthlink.net> > wrote:
Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.
if you are compiling with gcc (as opposed to qcc) then it will add
-D__CHAR_UNSIGNED__ if you pass -funsigned-char
qcc isn’t quite that smart, alas. :v(
Someone somewhere must set either CHAR_SIGNED or CHAR_UNSIGNED
otherwise <limits.h> would barf … looks like some magic in
<sys/compiler_*.h> tries to make appropriate assumptions …
Wojtek Lerch <wojtek_l@yahoo.ca> wrote:
Bill Caroselli <> qtps@earthlink.net> > wrote:
Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.#if CHAR_MIN == 0
But all of these things are keyed off whether CHAR_SIGNED or
CHAR_UNSIGNED is set, which I don’t think is correctly managed
with qcc.
\
“Colin Burgess” <cburgess@qnx.com> wrote in message
news:bhbliu$a0h$1@nntp.qnx.com…
Wojtek Lerch <> wojtek_l@yahoo.ca> > wrote:
Bill Caroselli <> qtps@earthlink.net> > wrote:Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.#if CHAR_MIN == 0
But all of these things are keyed off whether CHAR_SIGNED or
CHAR_UNSIGNED is set, which I don’t think is correctly managed
with qcc.
Then it’s a bug. But if you don’t use the -funsigned-char option with qcc,
it works fine.
Wojtek Lerch <wojtek_l@yahoo.ca> wrote:
WL > Bill Caroselli <qtps@earthlink.net> wrote:
Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.
WL > #if CHAR_MIN == 0
This did not work using the IDE under Windows-XP.
Bill Caroselli <qtps@earthlink.net> wrote:
Wojtek Lerch <> wojtek_l@yahoo.ca> > wrote:
WL > Bill Caroselli <> qtps@earthlink.net> > wrote:Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.WL > #if CHAR_MIN == 0
This did not work using the IDE under Windows-XP.
Then it’s broken. I don’t think you’ll find a way that works even with
broken headers and/or compiler.
Wojtek Lerch <wojtek_l@yahoo.ca> wrote:
Bill Caroselli <> qtps@earthlink.net> > wrote:
Wojtek Lerch <> wojtek_l@yahoo.ca> > wrote:
WL > Bill Caroselli <> qtps@earthlink.net> > wrote:Is there an #ifdef that I can use to test for if a char is signed or
not? Code that is compiling on two different system is being
interpreted differently.WL > #if CHAR_MIN == 0
This did not work using the IDE under Windows-XP.
Then it’s broken. I don’t think you’ll find a way that works even with
broken headers and/or compiler.
The fact of the matter is that the way gcc is setup, the compiler driver
is supposed to define CHAR_SIGNED or CHAR_UNSIGNED, which gcc does,
but qcc does not. This would be a useful addition to qcc, of course.
For now, you will either have to explicitly set this define according to
whether you are setting -funsigned-char or not.