Skip to content
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

cpplint incorrectly labels C++17 headers as C headers #309

Closed
jacobperron opened this issue Mar 25, 2021 · 5 comments · Fixed by #324
Closed

cpplint incorrectly labels C++17 headers as C headers #309

jacobperron opened this issue Mar 25, 2021 · 5 comments · Fixed by #324
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@jacobperron
Copy link
Contributor

Consider this example:

// Copyright 2021 Jacob Perron
#include <iostream>
#include <optional>

int main(void)
{
  return 0;
}

IIUC, following the Google C++ guide, it has the correct, alphabetically sorted, list of included C++ headers.

However, ament_cpplint complains that <optional> is a C header and should appear before <iostream>.

I've noticed that the same issue happens for all C++17 headers, e.g. <filesystem>. cpplint doesn't seem to be aware of them. Perhaps there is a patch upstream to fix this, but I haven't taken a look.

@jacobperron jacobperron added the bug Something isn't working label Mar 25, 2021
@wjwwood
Copy link
Contributor

wjwwood commented Mar 30, 2021

This also comes up for #include <variant>

@audrow audrow added the help wanted Extra attention is needed label May 7, 2021
@zflat
Copy link
Contributor

zflat commented Sep 20, 2021

@jacobperron Try building the latest cppcheck release from source (https://github.com/danmar/cppcheck/releases). If the problem persists then a ticket can be opened at https://trac.cppcheck.net/wiki.

@jacobperron
Copy link
Contributor Author

jacobperron commented Sep 20, 2021

@zflat The issue is with cpplint, not cppcheck.

cpplint.py was copied from the Google style guide here: https://github.com/google/styleguide/blob/71ec7f1e524969c19ce33cfc72e8e023f2b98ee2/cpplint/cpplint.py

I tried pulling in changes from upstream, but it doesn't appear to fix the issue. We may have to come up with a patch ourselves.

@jacobperron
Copy link
Contributor Author

Updating to a different version of cpplint seems to fix this issue. I've opened a PR #324 proposing we switch to tracking this fork: https://github.com/cpplint/cpplint

@aprotyas
Copy link
Contributor

@zflat The issue is with cpplint, not cppcheck.

On that note, this also happens with cppcheck. ros2/geometry2#464 had to specify the language manually, but that is orthogonal to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants