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

How to ignore a specific warning #662

Closed
spacemoose opened this issue Jun 13, 2015 · 4 comments
Closed

How to ignore a specific warning #662

spacemoose opened this issue Jun 13, 2015 · 4 comments

Comments

@spacemoose
Copy link

Just trying out flycheck, and find it awesome. Thanks for the great work.

Regarding my issue: Concretely, I get a warning (both gcc and clang) "#pragma once in main file" for all my header files that are included in a file providing main. This is incorrect, and from googling around seems to be a clang/gcc issue.

I would like to disable the warning -- have flycheck ignore this warning, and potentially others. How can I go about doing this?

Sorry if creating an issue is the wrong approach to answering my question, i tried stackexchange first...

@swsnr
Copy link
Contributor

swsnr commented Jun 14, 2015

You can't. Flycheck does not have its own way to ignore warnings, but relies on syntax checker to be able to ignore warnings on their own.

In other words, you'll need to find Clang's warning flag responsible for this warning, and add it to flycheck-clang-warnings or flycheck-clang-args. It's a Clang issue really, so closing.

@jcoffland
Copy link

I've changed flycheck-clang-warnings from the default value of ("all", "extra") to ("all") which should eliminate the #pragma once in main file warning but the warning persists. If I run clang or gcc on the command line I only get this warning with -Wextra. It appears that setting flycheck-clang-warnings or flycheck-gcc-warnings has no effect. Any idea how to fix this?

@cpitclaudel
Copy link
Member

Can you try running C-c ! C-c? It should show you exactly what command line flycheck ran.

@jcoffland
Copy link

That was very helpful. Here's what I got:

gcc -fshow-column -iquote /home/jcoffland/projects/camotics/git/master/src/gcode/plan/ -x c\+\+  -o /dev/null - < /home/jcoffland/projects/camotics/git/master/src/gcode/plan/Planner.h
<stdin>:21:9: warning: #pragma once in main file
In file included from <stdin>:23:0:
/home/jcoffland/projects/camotics/git/master/src/gcode/plan/PlannerConfig.h:23:10: fatal error: gcode/Axes.h: No such file or directory
 #include <gcode/Axes.h>
          ^~~~~~~~~~~~~~
compilation terminated.

There are two problems. One, I don't have my include paths setup correctly. Two, because of the way gcc is called it considers Planner.h to be a "main file" not a header. This causes it to emit the warning warning: #pragma once in main file. I cannot find any way to disable this warning in gcc but clang has -Wno-pragma-once-outside-header. So I'll just use clang with this option.

Now I just need to figure out how to get flycheck to use all of my project's include paths.

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

No branches or pull requests

4 participants