Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Problem compiling

This thread is locked; no one can reply to it. rss feed Print
Problem compiling
tobing
Member #5,213
November 2004
avatar

After some longer break, I have fetched the current sources and built. I encountered two problems, the other one is this:

I'm compiling with some more strict warnings, including stuff about signed unsigned. Now I get two errors, one in base.h and one in system.c, which relate to

Quote:

Commit hash: b4239e8613ef560ca2c182efb8e02e693ef412b1

Use -2147483648 instead of 1 << 31 for ALLEGRO_UNSTABLE_BIT.

The latter causes ubsan errors and implementation defined behavior
inside system.c and when passed to al_install_system, which, erroneously
imo, takes an int the version arg.

I think this should be safe from a BC point of view.

The warning looks like this:

1>t:\dev\ext\allegro51\src\allegro.c(29): error C2220: warning treated as error - no 'object' file generated
1>t:\dev\ext\allegro51\src\allegro.c(29): warning C4146: unary minus operator applied to unsigned type, result still unsigned
1>t:\dev\ext\allegro51\src\system.c(190): error C2220: warning treated as error - no 'object' file generated
1>t:\dev\ext\allegro51\src\system.c(190): warning C4146: unary minus operator applied to unsigned type, result still unsigned

I tried several things, including using (1<<31) instead of -2147483648, but things don't get better. It works with (1<<30), which is fine for me, but I guess that would break some compatibility when applied to the official allegro version.

SiegeLord
Member #7,827
October 2006
avatar

What compiler is this?

I think the error is wrong, but I suppose doing something like (-2147483647 - 1) might be a workaround. Your fix is fine too, for local development.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

tobing
Member #5,213
November 2004
avatar

I'm using Visual Studio 2017...

and I have tried a bit more. It turns out that INT_MIN is defined as (-2147483647 - 1) so something is strange here.
But I guess what is really meant here, is a specific bit, so why not use 0x10000000? That specifies the leftmost bit, and the compiler is fine with this as well.

Peter Hull
Member #1,136
March 2001

0x80000000 shurely

SiegeLord
Member #7,827
October 2006
avatar

0x80000000 ends up being interpreted as a an unsigned integer, and at that point it's unclear how to safely convert it to a signed integer. I ended up just using INT_MIN instead, which, incidentally, is defined as follows on my system:

#  define INT_MIN       (-INT_MAX - 1)
#  define INT_MAX       2147483647

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Go to: