0

I am trying to use the OutDir Macro from the Project properties within my c++ file to build a path.

But I can't find a way to assign the OutDir content to a variable in my code.

I tried this:

#define OUTPUT_DIR $OutDir

I can't seem to use this correctly.

hamza keurti
  • 385
  • 1
  • 2
  • 15
  • The project settings variables are not visible to the C++ compiler... You might try, however, to set the definition in the project settings (such that the definition is passed to the compiler via option `/D`). Don't know by heart, though, where *exactly* this is to be found in the project settings, have a look a the "preprocessor options". You'd have to set something like `OUTPUT_DIR="$OutDir"`. – Aconcagua Jun 07 '18 at 14:27

1 Answers1

1

You can specify pre-processor definitions in the "Project Properties->C/C++->Preprocessor->Preprocessor Definitions" list as:

OUTPUT_DIR=$(OutDir)

and then you can use that macro in your source code. You may need to textify it first. i.e.

#define TEXTIFY(x) #x

then use it as

TEXTIFY(OUTPUT_DIR)

see this answer. Although looking at this answer, it is possible that VC++ 2017 has some issues with this.

I believe you can also add the quotes into the options itself which might be a way round it.

OUTPUT_DIR="$(OutDir)"

CodingLumis
  • 594
  • 2
  • 22