Hi, I an trying to get version 2.5 working with our codebase, but am encountering a problem when using Boost include files. I am giving cppcheck a compilecommands.json cmake project file which for the file with a problem specifies the boost include directory as an '-isystem' path.
The file with a problem begins with these first 54 lines:
#ifndef MSGENERALPP_REFLECTIVE_STRUCT#define MSGENERALPP_REFLECTIVE_STRUCT#include<MSGeneralpp/ReferenceTuple.h>#include<boost/algorithm/string/join.hpp>#include<boost/format.hpp>#include<boost/preprocessor/seq/for_each.hpp>#include<boost/preprocessor/seq/transform.hpp>#include<boost/preprocessor/seq/enum.hpp>#include<boost/preprocessor/tuple/elem.hpp>#include<boost/preprocessor/tuple/size.hpp>#include<boost/preprocessor/tuple/eat.hpp>#include<boost/preprocessor/variadic/to_list.hpp>#include<boost/preprocessor/list/for_each.hpp>#include<boost/preprocessor/control/if.hpp>#include<boost/preprocessor/comparison/greater.hpp>#include<boost/preprocessor/punctuation/remove_parens.hpp>#include<boost/tti/has_type.hpp>#include<cstddef>#include<utility>#include<vector>...// Create a meta function "has_type_IAmReflective" that tells us whether a type// has an embedded declaration of a type called "IAmReflective".BOOST_TTI_HAS_TYPE(IAmReflective)
cppcheck always reports the following error for that last line:
<errorfile0="<path>/src/Geo/uniqueGaiaGeomCollPtr.cpp"id="unknownMacro"msg="There is an unknown macro here somewhere. Configuration is required. If BOOST_TTI_HAS_TYPE is a macro then please configure it."severity="error"verbose="There is an unknown macro here somewhere. Configuration is required. If BOOST_TTI_HAS_TYPE is a macro then please configure it."><locationcolumn="1"file="<path>/src/ReflectiveStruct.h"info=""line="54"/></error>
Given that I am tying to set thing up so that the same framework can be used for about 50 code bases, does anybody here have any suggestions about how to proceed? The code compiles and is in heavy use, as well as being written by an expert C++ developer.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the support. I will try that. One think that puzzles me is that I am giving the include path to the Boost include files via the cmake project file, so why doesn't cppcheck use the defines in those?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Daniel, MHR,
I can confirm that your suggestion worked. In addition, so far I have found 2 other boost macros that our code uses so the total that needed adding is:
Hi, I an trying to get version 2.5 working with our codebase, but am encountering a problem when using Boost include files. I am giving cppcheck a compilecommands.json cmake project file which for the file with a problem specifies the boost include directory as an '-isystem' path.
The file with a problem begins with these first 54 lines:
cppcheck always reports the following error for that last line:
The cppcheck command used was
Given that I am tying to set thing up so that the same framework can be used for about 50 code bases, does anybody here have any suggestions about how to proceed? The code compiles and is in heavy use, as well as being written by an expert C++ developer.
My desktop started behaving weird, so missed adding a thanks in advance to this
Normally, you would run cppcheck with
--library=boost
. However,BOOST_TTI_HAS_TYPE
is not part of boost.cfg. You could try and add this lineI agree with CHR. Please use
--library=boost
.If you do not want to edit boost.cfg now you could also edit the command line:
We should configure the BOOST_TTI_HAS_TYPE in boost.cfg for the next cppcheck release. cppcheck-2.7.
Thanks for the support. I will try that. One think that puzzles me is that I am giving the include path to the Boost include files via the cmake project file, so why doesn't cppcheck use the defines in those?
Daniel, MHR,
I can confirm that your suggestion worked. In addition, so far I have found 2 other boost macros that our code uses so the total that needed adding is:
Last edit: david ingamells 2021-10-06
Thanks, I have added them here: https://github.com/danmar/cppcheck/pull/3487