4

In my Premake file I go:

pchheader("../../"..dir_root.."stdafx.h")

I found that this at least partially works. (The invocation is somewhat different for ICC on Windows.)

When compiling, I get exactly one warning:

stdafx.h
../../mylibrary/stdafx.h:1:9: warning: #pragma once in main file
 #pragma once
         ^

I believe this comes from GCC compiling the precompiled header (as if it were some kind of main file). So, this warning is (kindof?) justified.

I would rather not remove the #pragma once which is obviously in stdafx.h (although I imagine that would fix the warning), because of builds not using the PCH.

Is that my only option, or is there something else I can do? I am tagging this both and , since a solution using either (e.g. change the compile arguments, call differently into Premake) would be fine.

geometrian
  • 14,775
  • 10
  • 56
  • 132

1 Answers1

0

Well, in C++, your main file (the file with your main function, int main(int argc, char * argv[]) should not have #pragma once because it is only for header files. So it seems as though your main function is in stdafx.h when it shouldn't be. If it is, put it in a .cpp file and include your header files there.

It is only a warning though, so don't fret.

ChaiNunes
  • 68
  • 12
  • Also, are you using Visual Studio? If so, generate an empty c++ project instead of a win32 application. – ChaiNunes Oct 08 '15 at 04:32
  • 1
    The warning occurs precisely when generating the PCH for `stdafx.h`. The problem is that it is generating a warning as if it were a translation unit. Also, this isn't related to project type (which affects runtime and target, not PCHes). – geometrian Oct 08 '15 at 07:18