warning: #pragma once in main file
We're running our headers through clang to get a partial AST.
Is it possible to disable that warning?
warning: #pragma once in main file
We're running our headers through clang to get a partial AST.
Is it possible to disable that warning?
Use the
-Wno-pragma-once-outside-header
command line argument. Consult the Clang documentation here.I had this thing when I accidentally included a header file in compile sources (this header has #pragma once line). To fix this remove header from compile sources (and probably you need to replace it with .cpp file)
There are no option to control it, so just ban this warning in your code.
Use the
-w
(lowercasew
not uppercaseW
) option while compiling the source to suppress such warnings.There's no
-W
option for "#pragma once in main file", so you can't turn it off via the usual means. (However, the Clang developers are very aware that warnings without-W
options suck, and there's a general rule that new warnings always get-W
options. Cleaning up the old code, unfortunately, is left as an exercise for frustrated users.)If you don't mind shell hackery, you could always do something like this:
The trailing
-
, as usual, means "read from stdin". The-x c++
tells Clang what language you're using (since it can't tell from the file extension when there is no file), and changingc++
toc++-header
means that we want to produce a .gch file instead of an .o file.The two
.gch
files thus produced are NOT bit-for-bit identical. I don't know enough about gch files to tell you what might be observably different about their behavior. However, since all you care about is Clang's AST, I bet you'll be fine with it. :)