0
votes
  1. FEATURE_FLAG is applicable to feature_folder - being newly introduced in the build system based on below condition in the top level makefile.

    ifdef FEATURE_AAA export FEATURE_FLAG=0 else export FEATURE_FLAG=1

  2. CPP and Header files inside the feature_folder further include some headers based on FEATURE_FLAG as below.

e.g. foo.cpp includes foo.h which has-

//Code
#if FEATURE_FLAG
#include <cstring>
#endif
//Code
a = memset(...);
//Code
  1. With the $(warning ...) prints in the makefiles corresponding to foo.cpp and foo.h, I have ensured that FEATURE_FLAG=1 just right before foo.cpp gets compiled. This means, the FEATURE_FLAG=1 setting works fine in the contained makefiles.

However, foo.cpp compilation gives the error as - memset not found.

If I comment the FEATURE_FLAG in the foo.h and include the cstring as default, the compilation works ok.

Q => Why doesn't the foo.h "see" the FEATURE_FLAG being set to 1?

CXX := arm-5.3-uclibc-1.0.12/usr/bin/arm-linux-g++
CC := arm-5.3-uclibc-1.0.12/usr/bin/arm-linux-gcc

1
Please take a few minutes after asking a question to read through it and examine its formatting, and if it's not formatted properly, edit the question. Thanks!MadScientist

1 Answers

0
votes

You have set the make variable FEATURE_FLAG. Make variables exist in your makefile, they do not exist (automatically) in your compiler when it compiles your code.

If you want to pass a value from your makefile into the compiler as a C or C++ preprocessor macro definition, you have to put it on the compiler's command line using the -D option.

You don't show enough of your makefile to be able to give exact instructions but assuming that you have a make variable CPPFLAGS that contains preprocessor definitions, you would do something like this:

CPPFLAGS += -DFEATURE_FLAG=$(FEATURE_FLAG)