I have code that is used across platforms (Windows and Linux). In windows the code uses precompiled headers so I include stdafx.h
but in linux I don't. So I have this at the top of every .cpp file:
#ifdef WIN32
#include "stdafx.h"
#endif // WIN32 // compiler error here
This compiles fine on linux but in Visual Studio 2013 I get the compiler error:
Error 2 error C1020: unexpected #endif
I think it is because stdafx.h
contains a #pragma once
macro.
How can I fix this and is there a better way to make the code cross-platform?