4

How do I concatenate two strings in an include statement?

I tried the code below - and also without ## - but both times, only the BASE_DIR part was output by the preprocessor.

#define BASE_DIR    "../Source/micropython/" /* Assume this file is in ATI_micropython/Headers */

#include BASE_DIR##"py/parse.h"

#include BASE_DIR ## "py/gc.h"
#include BASE_DIR ## "py/mpstate.h"
Bob
  • 4,576
  • 7
  • 39
  • 107
  • @Ron ok. How do I do that? – Bob Feb 04 '18 at 22:46
  • @Ron I tried `#include BASE_DIR+"py/gc.h"` but it was a compiler error – Bob Feb 04 '18 at 22:49
  • 1
    This sounds like an over-complex solution.Can you not just conditionally include one set of headers or a different set based on a macro? – Galik Feb 04 '18 at 22:52
  • @Galik I've been integrating a 3rd party library and having this very issue. – Bob Feb 04 '18 at 22:54
  • In fact this specific problem looks like what the *include root* compiler flags are designed to solve. `-I` on `GCC` not sure what `VC` uses – Galik Feb 04 '18 at 22:54
  • @Galik how do I mark my question as duplicate? – Bob Feb 04 '18 at 22:58

0 Answers0