Search code examples
c++visual-c++c-preprocessorpreprocessor-directive

Using preprocessor directives to define the output path


Using the following pseudo-code:

#define BUILD_PATH "C:/MyBuild/"
#define BUILD_NAME "mydll.dll"
// Set build path here

representing how I would like to build the current project (a dll) into C:/MyBuild/mydll.dll, how would I accomplish this by only using preprocessor directives?


Solution

  • I may be misunderstanding, but I really cannot understand WHY you want to do this but it is doable:

    #pragma comment( linker, "/out:c:\mydll.dll" )
    

    I cannot re-iterate enough exactly how much you don't want to be doing this though ...

    If you want to GET the output path via pre-processor info then, I'm afraid ... you can't. That info comes from several steps after the pre-processor so there is no way the pre-processor could get that info.