1

I have some variables defined in makefile.init:

MY_VARIABLE = some_value

In the preprocessor settings I have this -D switch:

-DUSE_MY_VAR=\"$(MY_VARIABLE)\"

And in a source file, I have this:

static const char* my_val = USE_MY_VAR;

So this my_val will get the value set in the makefile.init file.

It compiles just fine, but the indexer complains with a warning "Bad character sequence encountered: \". Is there a way to make it understand it or maybe make it ignore this specific variable?

Geob-o-matic
  • 5,940
  • 4
  • 35
  • 41

1 Answers1

2

Ok finally found something that make both compiler and indexer happy:

my -D switch becomes (removed the escaped quotes):

-DUSE_MY_VAR=$(MY_VARIABLE)

and in the source code (thanks to Expand macro inside string literal):

#define STRINGIFY2(X) #X
#define STRINGIFY(X) STRINGIFY2(X)

static const char* my_val = STRINGIFY(USE_MY_VAR);
Geob-o-matic
  • 5,940
  • 4
  • 35
  • 41