Page 1 of 1

define variable preprocessor (CPPFLAGS) in make comand line

Posted: Mon Nov 19, 2018 8:10 pm
by stoikos
Hi,
I would like to be able to #define variables from the make command line. I tried

Code: Select all

make -j12 CPPFLAGS+='-Dvar' all


and other combinations (CPPFLAGS='-Dvar', etc )and it seems that although the #define succeeds, it doesnt pick up other #defines that exist in the makefile and the compilation fails completely or I get some weird messages such as

Code: Select all

esp_http_client.c:(.text+0x1a96): dangerous relocation: call8: call target out of range: esp_log_timestamp

What is the correct way to #define a variable in the make command line?

[SOLVED] Re: define variable preprocessor (CPPFLAGS) in make comand line

Posted: Mon Nov 19, 2018 11:11 pm
by stoikos
C++ uses CXXFLAGS while C uses CPPFLAGS

Re: define variable preprocessor (CPPFLAGS) in make comand line

Posted: Mon Nov 19, 2018 11:58 pm
by ESP_igrr
On Make command line, or in the project makefile, you can use EXTRA_CPPFLAGS — these will be appended to CPPFLAGS without replacing anything.

Re: define variable preprocessor (CPPFLAGS) in make comand line

Posted: Tue Nov 20, 2018 12:57 am
by stoikos
so for C++ I need to add EXTRA_CXXFLAGS?

Re: define variable preprocessor (CPPFLAGS) in make comand line

Posted: Tue Nov 20, 2018 1:23 am
by ESP_igrr
CPPFLAGS are preprocessor flags, then apply both to C and C++. CFLAGS apply to C. CXXFLAGS apply to C++. Same with EXTRA_...

Re: define variable preprocessor (CPPFLAGS) in make comand line

Posted: Tue Nov 20, 2018 5:40 am
by stoikos
it worked ! thank you!