Search code examples
c++eclipseeclipse-cdt

Eclipse CDT: Define quoted string as preprocessor define


I have an eclipse CDT C++ project that has a bunch of unit tests. The tests need access to data that I put in a data directory in the same directory. I wanted to use a preprocessor define -Dtest_data_dir="<path/to/data/dir>" to specify the data directory to use.

It looks like this won't work due to this bug in eclipse. Given that, what is the best way to accomplish this? I could hard code the path to the data directory but then I'll have problems with out of source builds not finding the directory.


Solution

  • The linked bug report in question provides the answer. Since I just encountered the issue myself and Google brought me here first...

    The answer is to escape your double-quoted string in single quotes. ie:

    -Dtest_data_dir='"<path/to/data/dir>"'