Sharky
Sharky

Reputation: 383

C-file use a variable from makefile to c-file

How can a c-file use variables from a c-file?

makefile:

VARIABLE=$(shell grep textfile.txt | -c 66)

c-file pseudo code:

VARIABLE2 = VARIABLE;

Upvotes: 0

Views: 654

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753465

Usually by creating a macro passed to the C compiler, perhaps using some variation on the theme of:

CFLAGS += -DVARIABLE2="${VARIABLE}"

You have to worry about whether there are quotes etc in the value of the Make variable (I'm not familiar with the -c command shown in VARIABLE=$(shell grep textfile.txt | -c 66)).

Upvotes: 1

Related Questions