-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
failed to expand BOOST_MPL_AUX_NA_SPEC, Wrong number of parameters for macro BOOST_PP_TUPLE_ELEM #159
Comments
I don't know. If the "cppcheck -E" output looks wrong then it should be reported here. We can keep the issue here for now.
Yes certainly. In one project there is a workaround for boost macro problems. The project has this define:
Cppcheck does not handle this code well. To workaround this the code was updated to:
The preprocessor output is correct as far as I have seen but the A So what will happen now after this workaround... whenever the code uses the macro |
I meantime checked the manual and there (in section Include paths) it's written that "Actually, it is recommended to not give all include paths." and also "... passing standard library headers is highly discouraged because it will result in worse results and longer checking time.", so I'll proceed by passing only project's include paths to cppcheck, instead of all include paths like I was doing before. The issue could be closed. |
good! |
Hi, I'm having this same issue when including boost headers. For some reason, we ended up having all of our header in the same directory, so now cppcheck finds boost headers and we have the above error (and more I think). Is there a way to tell cppcheck to not use headers in headers_directory/boost ? Or can part of it be overridden via configuration ? The only thing I can think of is -D<BOOST_INCLUDES_GUARDS> for all the boost files (that we are using), but it sounds ugly. Any idea ? |
This preprocessor does not have any option to skip includes. I am not sure what you should do. You could probably generate the -D<BOOST_INCLUDES_GUARDS> with a script. I would put them in a file that you include with -include=... Unless you have lots of files, this might be an option:
Maybe adding some option to cppcheck would be ok also. Although I never got this feature request before so others seem to solve it somehow. I like to get inspiration from GCC so do you know if you can skip certain headers in GCC? |
Using -include=... is be a good idea, thanks
We do, it might still be an option, thanks !
To my knowledge, GCC does not support this "feature" (which, TBH, would be a bit weird for a compiler, if you don't want the include, don't pass -I...), the only thing a bit close is -iquote (which allow to pass some directory that GCC will search first. Is it worth trying to fix cppcheck so that I can understand the boost headers ? I have the feeling the it would be painful and that the answer is no. We'll probably go for one of the hack we discussed. |
That really sounds like a good solution. This is how I would do it personally.. I just thought from a "user" perspective before. If this is caused by a problem in simplecpp or cppcheck I think it should be fixed. |
Ok. I might give it a try (and I'll probably die in the middle because of all the preprocessing stuff that I won't understand :p). |
I've found something: Then, getMacroParameters is confused and in
it believes BOOST_PP_TUPLE_ELEM is called with 6 parameters, hence the error. The following fixes the issue. I've close to no idea what I am doing here, so it's probably not the right fix. I hope it gives you enough insight so that we can work out the right fix.
|
hmm.. that is interesting. The fix does not look wrong but I think I want to investigate this also. A short code example that reproduce the problem would be awesome! |
can I reproduce somehow? Is it enough to include some boost header and write some code? |
I believe including #include <boost/foreach.hpp> or boost/config.hpp is enough (I have not really tested though /o). Then there are other issues, in https://www.boost.org/doc/libs/1_52_0/boost/type_traits/detail/cv_traits_impl.hpp
goes wrong, then the evaluation also, and it defaults to 0.
and we end up with an extra '{', and the parsing fails with an error. Then, some boost files (at least cstdint.hpp) expects some constants defined b standard headers (things like UCHAR_MAX, UINT_MAX, etc). I stopped there and will make cppcheck ignore these files (either playing with -DBOOST... and --include, or removing the file). It might even make sense to ignore boost in simplecpp:
|
ok.. when I include foreach.hpp I get this error message from simplecpp:
Sounds like your problem. |
Here is a reduced code:
I hope it can be reduced further. But with
I am not sure but I have the feeling the #if condition is not calculated properly in simplecpp. I hope this code that I inserted can be reduced to ~ 2-5 lines |
@Ken-Patrick Can you try with the latest changes. After 229d41f , simplecpp seems to preprocess this code fine:
|
I ran into a similar issue with the wxWidgets macros that create a path for an include directive and found this similar bug report. My code (extracted from wx's setup.h and cpp.h) reproducing the problem using cppcheck:
|
@SpareSimian can you please try to create some little code sample I can test locally with simplecpp? and then please report it in a new issue. I assume the code you show is supposed to include some file but it's not easy to manually see which file.. |
Put the above sample in a .cpp file and cppcheck throws an error. It's trying to compute a string that looks like "../../../lib/vc142_x64_lib/mswud/setup.h". I copied the above into token_concat.cpp, loaded a clone of master into Visual Studio 2019, and got this:
|
You can replace the include directive with this to make it easier to see. I can reproduce it in the debugger in Visual Studio but I'm not familiar enough with the code to see how it fails. The final token is ")", though. static const char path[] = wxSETUPH_PATH_STR; |
I managed to shrink the failing sample down to this:
|
great! can you please create a new issue with that code. |
Hi, I am running |
I reopen this issue because people still have problems we'll need to solve it properly. |
I wasn't sure whether to report this here or in cppcheck project, so please excuse me if I chose the wrong place.
I stumbled upon the following problem when running cppcheck 1.87 on a C++ source using Boost libraries:
[/usr/include/boost/preprocessor/arithmetic/sub.hpp:47]: (error) failed to expand 'BOOST_MPL_AUX_NA_SPEC', Wrong number of parameters for macro 'BOOST_PP_TUPLE_ELEM'.
I checked this post in the forum, but the error message is not exactly the same. I guess it changed after the fix of #125, but issue #126 is still open and I think #108 is also related to the problem, because the problematic Boost header include/boost/preprocessor/arithmetic/sub.hpp uses ## operator.
Can I somehow workaround the problem until it's fixed in a new cppcheck version?
The text was updated successfully, but these errors were encountered: