devkitPro / newlib

fork from sourceware git://sourceware.org / newlib-cygwin.git
https://devkitpro.org
GNU General Public License v2.0
22 stars 16 forks source link

[devkitARM] newlib 4.4.0 update broke ``__restrict`` keyword in c++ (nds) #31

Closed edo9300 closed 5 months ago

edo9300 commented 8 months ago

As analyzed in this other conversation, in the commit https://github.com/devkitPro/newlib/commit/3c75fac130b5720068707f67b12f4372abf4ad38 (done by upstream) the logic whether to define or not __restrict keyword was changed, and now it is assumed to always be existing even in c++ mode, thus it's not redefined as an empty macro. Unfortunately the gcc shipped with dkp doesn't seem to support that keyword at all, even when compiling with gnu extensions (with -std=gnu++XX).

#include <sys/types.h>
#include <regex.h>

int main() {
    return 0;
}

Attempting to compile this sample code as cpp will error out

In file included from C:/devkitPro/examples/nds/templates/arm9/source/main.cpp:2:
C:/devkitPro/devkitARM/arm-none-eabi/include/regex.h:99:45: error: expected primary-expression before '__restrict'
   99 |                         size_t, regmatch_t [__restrict], int);
      |                                             ^~~~~~~~~~
C:/devkitPro/devkitARM/arm-none-eabi/include/regex.h:99:45: error: expected ']' before '__restrict'
   99 |                         size_t, regmatch_t [__restrict], int);
      |                                             ^~~~~~~~~~
      |                                             ]
C:/devkitPro/devkitARM/arm-none-eabi/include/regex.h:99:45: error: expected ')' before '__restrict'
   99 |                         size_t, regmatch_t [__restrict], int);
      |                                             ^~~~~~~~~~
      |                                             )
C:/devkitPro/devkitARM/arm-none-eabi/include/regex.h:98:16: note: to match this '('
   98 | int     regexec(const regex_t *__restrict, const char *__restrict,
      |                ^
C:/devkitPro/devkitARM/arm-none-eabi/include/regex.h:99:55: error: expected initializer before ']' token
   99 |                         size_t, regmatch_t [__restrict], int);

In this case the __restrict keyword is being used by the regex.h header, another component of newlib.

WinterMute commented 5 months ago

fixed with https://github.com/devkitPro/newlib/commit/5ff5c8ac6682bb2d59006e477f6dd9521a6d1bf6 and devkitARM release 64