Here is a minimal example:
// pch.h
#pragma once
#include <iostream>
And I run:
g++ -x c++-header -o pch.h.gch -c pch.hpp
When I run the command, I get
pch.h:1:9: warning: #pragma once in main file
1 | #pragma once
|
From my understanding, this behavior is intended by GCC after reading their bugzilla bug tracker; so, this is not a bug but a feature.
How can I disable this warning? Is there a warning number or name that I can suppress by adding it as a pragma statement:
#pragma GCC diagnostic ignored "-Wcan-i-set-something-here"
From my understanding, this behavior is intended by GCC
As far as I can tell, it's a bug.
How can I disable this warning?
Unfortunately, it appears that you cannot since the warning cannot be controlled by an option. In my opinion, this is a bug as well.
You can circumvent the issue by using a header guard instead of #pragma once
.