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.

1
  • 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". Commented Jun 7, 2018 at 14:27

1 Answer 1

2

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)"

Sign up to request clarification or add additional context in comments.

1 Comment

I defined OUTPUT_DIR with the double quotes method and it works. I am on VS2015. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.