Skip to content

Conversation

@pfultz2
Copy link
Contributor

@pfultz2 pfultz2 commented Dec 6, 2025

Cppcheck passes a pointer and size to simplecpp:TokenList, so we need those APIs enabled even if there is string_view and span.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 6, 2025

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.. @firewave ?

@firewave
Copy link
Collaborator

firewave commented Dec 7, 2025

It would be helpful if the error which is fixed by this could be provided.

Also I think this has nothing to do with libc++ but actually with a compiler which bypasses the standard version we are setting. I think the "proper" fix would be #7962.

@firewave
Copy link
Collaborator

firewave commented Dec 7, 2025

Also I think this has nothing to do with libc++ but actually with a compiler which bypasses the standard version we are setting.

I am not able to reproduce it, so either your compiler is misbehaving or you have CMake misconfigured.

@pfultz2
Copy link
Contributor Author

pfultz2 commented Dec 9, 2025

This is the error I see:

/Users/paul/github/danmar/cppcheck/lib/cppcheck.cpp:877:16: error: no matching constructor for initialization of 'simplecpp::TokenList'
        return simplecpp::TokenList{data, size, files, file.spath(), outputList};
               ^                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/paul/github/danmar/cppcheck/externals/simplecpp/./simplecpp.h:230:9: note: candidate constructor not viable: requires at most 4 arguments, but 5 were provided
        TokenList(std::istream &istr, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr);
        ^
/Users/paul/github/danmar/cppcheck/externals/simplecpp/./simplecpp.h:254:9: note: candidate constructor not viable: requires at most 4 arguments, but 5 were provided
        TokenList(std::string_view data, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
        ^
/Users/paul/github/danmar/cppcheck/externals/simplecpp/./simplecpp.h:345:9: note: candidate constructor not viable: requires 6 arguments, but 5 were provided
        TokenList(const unsigned char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList, int unused);
        ^
/Users/paul/github/danmar/cppcheck/externals/simplecpp/./simplecpp.h:271:9: note: candidate constructor not viable: requires at most 3 arguments, but 5 were provided
        TokenList(const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList = nullptr);
        ^
/Users/paul/github/danmar/cppcheck/externals/simplecpp/./simplecpp.h:228:18: note: candidate constructor not viable: requires single argument 'filenames', but 5 arguments were provided
        explicit TokenList(std::vector<std::string> &filenames);
                 ^
/Users/paul/github/danmar/cppcheck/externals/simplecpp/./simplecpp.h:272:9: note: candidate constructor not viable: requires single argument 'other', but 5 arguments were provided
        TokenList(const TokenList &other);
        ^
/Users/paul/github/danmar/cppcheck/externals/simplecpp/./simplecpp.h:273:9: note: candidate constructor not viable: requires single argument 'other', but 5 arguments were provided
        TokenList(TokenList &&other);
        ^

Its calling the constructor that takes a pointer and size:

return simplecpp::TokenList{data, size, files, file.spath(), outputList};

but the constructor is not available when SIMPLECPP_TOKENLIST_ALLOW_PTR is not defined. That is only defined when string_view and span is not available:

# define SIMPLECPP_TOKENLIST_ALLOW_PTR

Since this is c++17, string_view is available but span is not, so this macro doesnt get defined.

I think the "proper" fix would be #7962.

I agree but since this fails to build completely, I think this can be merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants