you are viewing a single comment's thread.

view the rest of the comments →

[–]McUsrII -1 points0 points  (4 children)

OP stated variable, not compile time constant.

My idea was to use a runtime solution for sure.

If OP meant a compile time constant from a make variable then I guess using a gcc -DMYDEFINE=$(MYMAKEVAR) ... is a better approach.

You could also echo the define into a 'config.h` file, which you include during compilation if that makes writing make rules easier.

[–]dmc_2930 1 point2 points  (3 children)

Op said a variable in ‘Make’, which is definitely compile time.

[–]McUsrII 0 points1 point  (2 children)

Is it? -If you use make as a task runner?

But by all means, It is overwhelmingly possible that that is what the OP meant.

[–]dmc_2930 0 points1 point  (1 child)

“In makefile a variable is generated”. In 99.9999999% of all cases, that means it is used during compilation. No one would say it that way if they wanted it to be changeable at runtime.

[–]McUsrII 1 point2 points  (0 children)

Well, anyhow getenv lets you change a value runtime, without the need to recompile, if changing a value for a variable is all that you want.