make code run both under visual studio and linux g++?
i need to create a project that able to run both under linux and windows(visual studio)... i pretty much finish all coding and able to run both windows and linux in separate files
the problem i deal with is the header file
which visual studio required #include "StdAfx.h" and not found in G++ under linux
i tried to #ifndef and #ifdef to fix it in this way, but visual studio still gives me a compiler error. so how should fix to make it works under both in Linux(g++) and windows(visual studio)?
#ifdef WIN32 (also tried ifndef)
#include "StdAfx.h"
....
#endif
codes...
wildplace
Junior Poster in Training
63 posts since Dec 2009
Reputation Points: 10
Solved Threads: 4
Why are you using StdAfx.h? That's your major problem.
Write the code based on the C++ Standard and the program should compile in both environments. Don't use any of Visual Studio's cutesy enhancements at all.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
but if I don't use stdafx. vs would give me a precompiled header error.so how would I fix this problem without including stdafx? btw, thanks for helping me out in the last thread
it is a win32 console project..
wildplace
Junior Poster in Training
63 posts since Dec 2009
Reputation Points: 10
Solved Threads: 4
Yes, when you make a project in VC++ untick the box "use precompiled headers". You can delete stdafx.h and then set "Precompiled Header Support" (something along those lines to NO in the project properties page.
jbennet
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
thanks all!! i just see the "precompiled headers"
works perfectly fine now!
wildplace
Junior Poster in Training
63 posts since Dec 2009
Reputation Points: 10
Solved Threads: 4