jorgen / json_struct

json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Other
422 stars 57 forks source link

JS_OBJ_EXT triggers "ISO C++11 requires at least one argument for the "..." in a variadic macro" warning #30

Closed noodlecollie closed 2 years ago

noodlecollie commented 2 years ago

I get this warning when compiling with GCC 10.3.0, which is a bit of an issue for me since my repo is configured to treat warnings as errors, and these warnings are difficult to turn off because they don't seem to have a -Wno-... switch. As the related code is generated inline from the macros, I'd have to switch either the pedantic or warnings-as-errors settings off for my whole repo. Is there a way to resolve this properly?

jorgen commented 2 years ago

Hello! I remember seeing this a while ago as well, and I was looking into it, but now I can not reproduce it. Here is what I tried now: https://godbolt.org/z/d1W9xhMqP

I can not remember what I resulted with the warning, but I must have thought of a workaround somehow, since I'm also a fan of using -Wall -Wextra -pedantic -Werror.

Can you help me reproduce this again?

jorgen commented 2 years ago

I am aware of the warning regarding 128 bit ints. I'm working on a fix.

noodlecollie commented 2 years ago

Hmm, I'll see if I can get a minimal example working on my computer.

noodlecollie commented 2 years ago

Aha, the flag you were missing from the Godbolt PoC seems to be -std=c++11. If I add that, or the equivalent for C++ standards 14 or 17, the warnings appear.

jorgen commented 2 years ago

Ok, I am a bit preoccupied, but i think I know how to fix it. Should have something by the end of the week.

noodlecollie commented 2 years ago

Nice one, thanks!

jorgen commented 2 years ago

That was pretty difficult, but I think I have nailed it. 6b897bbab39d73cf8dc749f6f860e7c4caddcbfd should remove the warnings. I think it should compile without warnings now on all 3 major compilers with most warnings enabled. I gladly accept fixes for warnings. I'm also working on compiling everything except the benchmark test with -Werror and /Wx, but there is some bits missing.