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

cc: use '-x c*-header' for header files for C and C++ linters. #4318

Merged
merged 1 commit into from
Sep 25, 2022
Merged

cc: use '-x c*-header' for header files for C and C++ linters. #4318

merged 1 commit into from
Sep 25, 2022

Conversation

nicopauss
Copy link
Contributor

Fix #4096

When linting an header file in C or C++, -x c-header or -x c++-header should be used instead of -x c or -x c++.

Using -x c or -x c++ for headers files can lead to unused variables and functions marked as static inlined as seen in #4096.

Using -x c-header or -x c++-header solve these issues.

The list of file extensions that are considered as header files can be configured with the variables g:ale_c_cc_header_exts and g:ale_cpp_cc_header_exts.

When linting an header file in C or C++, `-x c-header` or
`-x c++-header` should be used instead of `-x c` or `-x c++`.

Using `-x c` or `-x c++` for headers files can lead to unused variables
and functions marked as static inlined as seen in #4096.

Using `-x c-header` or `-x c++-header` solve these issues.

The list of file extensions that are considered as header files can be
configured with the variables `g:ale_c_cc_header_exts` and
`g:ale_cpp_cc_header_exts`.
Copy link
Contributor

@hsanson hsanson left a comment

Choose a reason for hiding this comment

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

Thanks, looks good.

@hsanson hsanson merged commit 78942df into dense-analysis:master Sep 25, 2022
nicopauss added a commit to nicopauss/sh-tools that referenced this pull request Sep 29, 2022
@laoshaw
Copy link

laoshaw commented Oct 7, 2022

I use g++ as one of my linter in ale_linters

g++-11 -S -x c++-header - < test.hpp reports fatal error: cannot use ‘-’ as input filename for a precompiled header, now I have that shown in the quickfix window every time I save the header file.

the old method g++-11 -S -x c++ - < test.hpp worked flawlessly instead

@laoshaw
Copy link

laoshaw commented Oct 7, 2022

Thanks, looks good.

this breaks cc as the linter badly, see above.

@nicopauss
Copy link
Contributor Author

Oh sorry about that. I though I have tested it with GCC, but I must have messed my config while testing and only tested with clang.
I'll try to make a fix ASAP.
In the meanwhile, you can set g:cpp_cc_header_exts to []: let g:ale_cpp_cc_header_exts = []

@laoshaw
Copy link

laoshaw commented Oct 7, 2022

looking for a fix, as the workaround will totally ignoring cpp headers. Thanks.

@nicopauss
Copy link
Contributor Author

Fix here: #4334

mnikulin pushed a commit to mnikulin/ale that referenced this pull request Nov 12, 2023
…-analysis#4318)

When linting an header file in C or C++, `-x c-header` or
`-x c++-header` should be used instead of `-x c` or `-x c++`.

Using `-x c` or `-x c++` for headers files can lead to unused variables
and functions marked as static inlined as seen in dense-analysis#4096.

Using `-x c-header` or `-x c++-header` solve these issues.

The list of file extensions that are considered as header files can be
configured with the variables `g:ale_c_cc_header_exts` and
`g:ale_cpp_cc_header_exts`.
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.

Linting C/C++ headers - unused variables, non-declared, wrong types...
3 participants