https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89808

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to sduguay from comment #3)
> (In reply to Richard Biener from comment #1)
> > Testcase:
> > 
> > #pragma once
> > int main() {}
> > 
> > > g++ t.C -S
> > t.C:1:9: warning: #pragma once in main file
> >  #pragma once
> >          ^~~~
> > 
> > 
> > you could work around this by wrapping the pragma in a preprocessor
> > conditional
> 
> Hi, thanks for adding a minimal test case. I tried:
> 
> #if 1
> #pragma once
> #endif
> 
> but I'm still getting the warning.

I of course meant

#if !defined(THIS_IS_THE_MAIN_FILE)
#pragma once
#endif

and compile the main file with -DTHIS_IS_THE_MAIN_FILE

Reply via email to