Does the preprocessor pass environment variables? -


does preprocessor have mechanism access environment variables directly defines, without need define them on command line?

for instance,

some_var=foo gcc code.c 

and

#if env_some_var == "foo" #define some_var_is_foo #endif 

no, standard c preprocessor has no such mechanism, , i'm not aware of compiler extensions provide such feature either.

however, can using build system, such cmake or gnu autoconf, latter being part of gnu autotools build system. simple shell script well, though of these options mean you'd need test environment variable determine whether define env_some_var, in case, might define using following:

-denv_some_var="${some_var:-unfoo}" 

that define env_some_var in c file value of $some_var if it's set or string "unfoo" if $some_var empty (null) or unset.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -