Makopo/lslint

variadic macros error on Linux32 and OSX

Closed this issue · 8 comments

on Linux32:

$ ./creator_linux.sh 
bison -d lslmini.y
g++ -g -Wall -std=c++98 -pedantic-errors -fno-omit-frame-pointer -ffloat-store   -DVERSION='"1.0.9"' -DBUILD_DATE='"2017-12-08"' -o"lslmini.tab.o" -c lslmini.tab.c
In file included from ast.hh:5:0,
                 from lslmini.hh:29,
                 from lslmini.y:2:
logger.hh:144:19: error: ISO C++ does not permit named variadic macros [-Wvariadic-macros]
 #define DEBUG(args...)
                   ^
Makefile:125: recipe for target 'lslmini.tab.o' failed
make: *** [lslmini.tab.o] Error 1

on OSX:

$ ./creator_osx.sh 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 49661  100 49661    0     0  23555      0  0:00:02  0:00:02 --:--:-- 24694
bison -d lslmini.y
g++ -g -Wall -std=c++98 -pedantic-errors -fno-omit-frame-pointer -ffloat-store -arch i386   -DVERSION='"1.0.9"' -DBUILD_DATE='"2017-12-08"' -o"lslmini.tab.o" -c lslmini.tab.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: optimization flag '-ffloat-store' is not supported [-Wignored-optimization-argument]
In file included from lslmini.y:2:
In file included from ./lslmini.hh:29:
In file included from ./ast.hh:5:
./logger.hh:144:19: error: named variadic macros are a GNU extension
      [-Werror,-Wvariadic-macros]
#define DEBUG(args...)
                  ^
In file included from lslmini.y:2:
In file included from ./lslmini.hh:28:
./symtab.hh:62:26: warning: private field 'cur_references' is not used
      [-Wunused-private-field]
    int                  cur_references;        // how many times the cu...
                         ^
1 warning and 1 error generated.
make: *** [lslmini.tab.o] Error 1

Just removing the __GNUC__ condition and leaving DEBUG(...) works for me. There's no need for named variadic args there.

--- a/logger.hh
+++ b/logger.hh
@@ -140,11 +140,7 @@ enum AssertType {
 #ifdef DEBUG_LEVEL
 #define DEBUG LOG
 #else /* not DEBUG_LEVEL */
-#ifdef __GNUC__
-#define DEBUG(args...)
-#else /* not __GNUC__ */
 #define DEBUG(...)
-#endif /* not __GNUC__ */
 #endif /* not DEBUG_LEVEL */
 #endif /* not _MSC_VER */

Thank you for investigation. This project are now built with -std=c++98 option introduced by #65.
Even anonymous variadic macros were introduced at c99, it still throws error.

Ahh crap! I have no idea how to get out of that one then. For some reason, my compiler doesn't catch those. Which compiler / version are you using?

The possibilities that come to my mind are:

  • change -std=c++99 to -std=gnu++99
  • replace #define DEBUG(...) with static inline void DEBUG(...) { }

either of which is ugly as hell.

On Mac:

$ g++ --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.2.0
Thread model: posix

On Linux32:

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

Both -std=c++99 and -std=gnu++99 threw a error as a invalid option.
Thanks.

Thanks. Well, let's go for the ugly but guaranteed-standard hack.

I take it that the PR fixed it. How come Travis didn't complain? Maybe it's using the same compiler I'm using. This looks like a regression in GCC.

For the record:

$ g++ --version
g++ (Debian 6.3.0-18) 6.3.0 20170516

Never mind. I was being dumb. I could reproduce it with make DEBUG=.

Thank you for heads-up anyway.