Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey out there,

i have a question about Preprocessor makros.

is there a way to do something like:
C++
#if COMPUTER_NAME == _T("TestPC") // only on the test computer
   #import "C:\Path\To\3thParty\Library"
#else // on our dev computers
   #import "D:\Dev\Path\To\3thParty\Libraries" 
#endif

that the "C:\" path is only used, when compile on the test computer and in all other cases the "D:\" path is used?

Thank you so much guys for your help!
Posted

Yes: the simplest way is to use
C++
#IF DEBUG
as you (should) always compile with debug off for production releases.
 
Share this answer
 
Comments
C3D1 22-Aug-14 4:11am    
#ifded _DEBUG doesen't work in this case, because the test computer sould do debug too.
And the computer who compile the release version have the same paths and harddrives like our dev computers. Only the test computer have different paths
I have looked over this issue. You need to do following to get what you want.

* On Your test machine open VS
* Goto: Project->Properties->Configuration Properties->C/C++->PreProcessor
* Add _TEST_MACHINE at the end in Preprocessor Definition
* Change your macro like this
C++
#if _TEST_MACHINE 
   #import "C:\Path\To\3thParty\Library"
#else 
   #import "D:\Dev\Path\To\3thParty\Libraries" 
#endif


Please do remember not to add _TEST_MACHINE on your devlopment machine's VS
 
Share this answer
 
v3
Comments
C3D1 22-Aug-14 7:13am    
Sorry, i'm using VC++ not C#
No you cannot use strings in preprocessor directives in that way; see http://msdn.microsoft.com/en-us/library/ew2hz0yd.aspx[^].
 
Share this answer
 
Comments
C3D1 22-Aug-14 7:15am    
yes, i know that i cannot use strings in preprocessor directives in the way i asked.
I wrote "something like". I know the code above will not work.
Therfore i ask, if there is a way to do something like that
Richard MacCutchan 22-Aug-14 7:30am    
Yes but only by defining a preprocessor constant that tells the compiler which path to take. A much simpler option is to use the search order rules as described in the documentation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900