gbdev / rgbds

Rednex Game Boy Development System - An assembly toolchain for the Nintendo Game Boy and Game Boy Color
https://rgbds.gbdev.io
MIT License
1.33k stars 175 forks source link

Build failure on gcc 10.2 #1139

Closed clbr closed 1 year ago

clbr commented 1 year ago
In file included from src/asm/charmap.c:22:
include/hashmap.h:17:27: error: expected declaration specifiers or '...' before numeric constant
   17 | #define HALF_HASH_NB_BITS 16
      |                           ^~
include/hashmap.h:18:15: note: in expansion of macro 'HALF_HASH_NB_BITS'
   18 | static_assert(HALF_HASH_NB_BITS * 2 == HASH_NB_BITS, "");

Changing static_assert to _Static_assert fixes the build.

aaaaaa123456789 commented 1 year ago

hashmap.h includes <assert.h>, which defines the static_assert macro in C11 and C17. What's your system/platform?

clbr commented 1 year ago

assert.h comes from glibc, not gcc. This system's glibc is older and its assert.h does not define that.

CasualPokePlayer commented 1 year ago

Then your system glibc is not C11 compliant (or so not enough compliant for rgbds). glibc added the static_assert macro over 11 years ago, you really should upgrade.

clbr commented 1 year ago

The GBC was released 25 years ago ;)

It's fine to close this if you don't want to support older setups, this would be a simple change though.

aaaaaa123456789 commented 1 year ago

The issue is that this is a bottomless pit of mini-fixes. "Older setups" can mean all sorts of non-conforming things, not just this one. How long until someone comes around with their copy of GCC 2.95 and asks why it can't build RGBDS?

Your problem can be trivially solved by putting conformant headers in your include path, anyway.

(And anyway, the issue title is misleading — the GCC version has nothing to do with anything here. You knew this, as you diagnosed the issue yourself, so why did you put it there?)

clbr commented 1 year ago

I can send a PR if it's an issue of who does the work?

clbr commented 1 year ago

Oh, you edited the post. I put in the gcc version because otherwise you'd have complained I must have been using a too old gcc, obviously.

CasualPokePlayer commented 1 year ago

You're using glibc version that came out before gcc even had _Static_assert implemented in the first place. You're using a dramatically newer compiler compared the glibc version you have.

aaaaaa123456789 commented 1 year ago

Oh, you edited the post. I put in the gcc version because otherwise you'd have complained I must have been using a too old gcc, obviously.

You're using an ancient toolchain. It's just that it's a different part of the toolchain causing the problem.

clbr commented 1 year ago

Yes. Do you want to close this or me to send a PR?

ISSOtm commented 1 year ago

Tbh, the change is minimal (adding an underscore and capitalising one letter), so I'm fine with a change being submitted to increase compat ever so slightly. (As long as it doesn't break anyone else, hopefully.)

aaaaaa123456789 commented 1 year ago

Tbh, the change is minimal (adding an underscore and capitalising one letter), so I'm fine with a change being submitted to increase compat ever so slightly. (As long as it doesn't break anyone else, hopefully.)

It shouldn't break any builds, as _Static_assert is a keyword from C99 on. (C23 will introduce static_assert as a keyword, but without removing the existing one.)

CasualPokePlayer commented 1 year ago

The worst it could do is break somebody trying to include the header in a C++ context (no _Static_assert there, only static_assert), but that'd be dumb here, you have std::unordered_map in C++ (and hashmap.h isn't included in any other headers).

clbr commented 1 year ago

Oh, if it's becoming a keyword, then nothing needs to be done. At that point gcc would handle it internally, and such upgraded systems would work fine with it. Closing.