Julien
Julien

Reputation: 1910

using GCC -D option

I did a minimal c file (main.c)

#if !defined(MBEDTLS_CONFIG_FILE)
    #error "not defined"
#else
    #include MBEDTLS_CONFIG_FILE
#endif

int main(void)
{
    while(1);
}

now calling arm-none-eabi-gcc main.c gives error: #error "no defined" and this is OK.

But calling arm-none-eabi-gcc main.c -DMBEDTLS_CONFIG_FILE="test.h" gives error: #include expects "FILENAME" or <FILENAME> so it is defined but not to the value I expect.

What is the correct syntax ? (context: this is working from the IDE but I want to move to cmake)

Upvotes: 1

Views: 767

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409196

It's the shell that removes the quotes from the string you pass. You need to escape the quotes to keep them in the macro:

arm-none-eabi-gcc main.c -DMBEDTLS_CONFIG_FILE=\"test.h\"

Upvotes: 3

Related Questions