Re: LLONG_MAX not available from c++
On Fri, 31 Mar 2023, Valery Ushakov wrote: On Fri, Mar 31, 2023 at 15:25:02 +, RVP wrote: You have to create an empty file for `-E -dM' to work correctly: Not necessary, -x c++ is enough, but that's a very common pitfall indeed. Great! thanks... now I won't have to create superfluous empty files :) -RVP
Re: LLONG_MAX not available from c++
On Fri, Mar 31, 2023 at 03:30:56PM -, Michael van Elst wrote: > There is magic involved. You mean: there are bugs - bah :-/ Martin
Re: LLONG_MAX not available from c++
On Fri, Mar 31, 2023 at 15:25:02 +, RVP wrote: > You have to create an empty file for `-E -dM' to work correctly: Not necessary, -x c++ is enough, but that's a very common pitfall indeed. # c, despite being called as c++ $ g++ -dM -E - < /dev/null | egrep -i 'stdc|plus' #define __STDC_HOSTED__ 1 #define __STDC_UTF_16__ 1 #define __STDC_VERSION__ 201112L #define __GNUC_STDC_INLINE__ 1 #define __STDC_UTF_32__ 1 #define __STDC__ 1 # needs explicit language selection with -x or an an input file suffix $ gcc -x c++ -dM -E - < /dev/null | egrep -i 'stdc|plus' #define __STDC_HOSTED__ 1 #define __cplusplus 199711L #define __STDC__ 1 -uwe
Re: LLONG_MAX not available from c++
mar...@duskware.de (Martin Husemann) writes: > > c++ -dM -E - < /dev/null | fgrep __STDC_VERSION__ >#define __STDC_VERSION__ 201710L > > c++ -dM -E - < /dev/null | fgrep __ISO There is magic involved. % touch c.c % ls -l c.c -rw-r--r-- 1 mlelstv staff 0 Mar 31 17:28 c.c % c++ -dM -E - < c.c | grep STDC #define __STDC_HOSTED__ 1 #define __STDC_UTF_16__ 1 #define __STDC_VERSION__ 201710L #define __GNUC_STDC_INLINE__ 1 #define __STDC_UTF_32__ 1 #define __STDC__ 1 % c++ -dM -E c.c | grep STDC #define __STDC_HOSTED__ 1 #define __STDC_UTF_16__ 1 #define __GNUC_STDC_INLINE__ 1 #define __STDC_UTF_32__ 1 #define __STDC__ 1
Re: LLONG_MAX not available from c++
On Fri, 31 Mar 2023, Martin Husemann wrote: On Fri, Mar 31, 2023 at 02:27:17PM -, Michael van Elst wrote: c++ also doesn't define __STDC_VERSION__ nor _ISOC99_SOURCE. It defines the former but not the latter: > c++ -dM -E - < /dev/null | fgrep __STDC_VERSION__ #define __STDC_VERSION__ 201710L > c++ -dM -E - < /dev/null | fgrep __ISO > (at least w/o special -std= options) You have to create an empty file for `-E -dM' to work correctly: $ > x.c $ cc -E -dM x.c | fgrep STDC_VERSION #define __STDC_VERSION__ 201710L $ c++ -E -dM x.c | fgrep STDC_VERSION $ Thomas, add `-D_NETBSD_SOURCE' to `MYCFLAGS'. That should work. As Michael pointed out, a C++ compiler doesn't define __STDC_VERSION__ and the NetBSD limits.h doesn't test for `__cplusplus'. -RVP
Re: LLONG_MAX not available from c++
On Fri, Mar 31, 2023 at 02:27:17PM -, Michael van Elst wrote: > c++ also doesn't define __STDC_VERSION__ nor _ISOC99_SOURCE. It defines the former but not the latter: > c++ -dM -E - < /dev/null | fgrep __STDC_VERSION__ #define __STDC_VERSION__ 201710L > c++ -dM -E - < /dev/null | fgrep __ISO > (at least w/o special -std= options) Martin
Re: LLONG_MAX not available from c++
w...@netbsd.org (Thomas Klausner) writes: >> Make sure c++ with using at least -std=c++11? >Same error, also with c++17 and gnu++17. Probably lua does something >weird. lua defines _XOPEN_SOURCE in lprefix.h: #if !defined(_XOPEN_SOURCE) #define _XOPEN_SOURCE 600 #elif _XOPEN_SOURCE == 0 #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ #endif That's why it's no longer _NETBSD_SOURCE (featuretest). c++ also doesn't define __STDC_VERSION__ nor _ISOC99_SOURCE. And so limits.h doesn't define LLONG_MAX. >From what I found LLONG_MAX should also be defined for C++11 and later, then limits.h should also check for __cplusplus >= 201100L.
Re: LLONG_MAX not available from c++
On Fri, Mar 31, 2023 at 02:46:18PM +0200, Joerg Sonnenberger wrote: > Am Fri, Mar 31, 2023 at 02:39:40PM +0200 schrieb Thomas Klausner: > > On Fri, Mar 31, 2023 at 02:35:38PM +0200, Martin Husemann wrote: > > > Which options does it pass to g++ ? > > > > Good point, but it's not the compiler, it's lua itself: > > > > tar xvzf lua-5.4.4.tar.gz > > cd lua-5.4.4/src > > c++ lbaselib.c > > > > and see it fail. > > > > In file included from lua.h:16, > > from lbaselib.c:18: > > luaconf.h:557:2: error: #error "Compiler does not support 'long long'. Use > > option '-DLUA_32BITS' or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for > > details)" > > 557 | #error "Compiler does not support 'long long'. Use option > > '-DLUA_32BITS' \ > > | ^ > > Make sure c++ with using at least -std=c++11? Same error, also with c++17 and gnu++17. Probably lua does something weird. > Also, to ensure stack > unwinding for C, -fexceptions should be enough. Thanks for the information. I don't expect I'd get MAME to change to that though. Thomas
Re: LLONG_MAX not available from c++
Am Fri, Mar 31, 2023 at 02:39:40PM +0200 schrieb Thomas Klausner: > On Fri, Mar 31, 2023 at 02:35:38PM +0200, Martin Husemann wrote: > > Which options does it pass to g++ ? > > Good point, but it's not the compiler, it's lua itself: > > tar xvzf lua-5.4.4.tar.gz > cd lua-5.4.4/src > c++ lbaselib.c > > and see it fail. > > In file included from lua.h:16, > from lbaselib.c:18: > luaconf.h:557:2: error: #error "Compiler does not support 'long long'. Use > option '-DLUA_32BITS' or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for > details)" > 557 | #error "Compiler does not support 'long long'. Use option > '-DLUA_32BITS' \ > | ^ Make sure c++ with using at least -std=c++11? Also, to ensure stack unwinding for C, -fexceptions should be enough. Joerg
Re: LLONG_MAX not available from c++
On Fri, Mar 31, 2023 at 02:35:38PM +0200, Martin Husemann wrote: > Which options does it pass to g++ ? Good point, but it's not the compiler, it's lua itself: tar xvzf lua-5.4.4.tar.gz cd lua-5.4.4/src c++ lbaselib.c and see it fail. In file included from lua.h:16, from lbaselib.c:18: luaconf.h:557:2: error: #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" 557 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ | ^ Thomas
Re: LLONG_MAX not available from c++
On Fri, Mar 31, 2023 at 02:10:46PM +0200, Thomas Klausner wrote: > g++ in -current doesn't get this symbol when you include limits.h > (which lua does, since this is still C code) because of (from > /usr/include/machine/limits.h): > > #if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ > defined(_NETBSD_SOURCE) > #define ULLONG_MAX 0xULL /* max unsigned long long */ > #define LLONG_MAX 0x7fffLL/* max signed long long */ Which options does it pass to g++ ? For me just invoking "g++" defines __STDC_VERSION__ as 201710L, so should get the symbol: > g++ -dM -E - < /dev/null | fgrep STDC #define __STDC_UTF_16__ 1 #define __STDC_VERSION__ 201710L #define __GNUC_STDC_INLINE__ 1 #define __STDC_UTF_32__ 1 #define __STDC__ 1 #define __STDC_HOSTED__ 1 Martin