How to pass macro definition from “make” command line arguments (-D) to C source code?

前端 未结 6 1911
醉话见心
醉话见心 2020-12-04 07:40

I usually pass macro definitions from \"make command line\" to a \"makefile\" using the option : -Dname=value. The definition is accessible inside the makefile.

I al

6条回答
  •  执笔经年
    2020-12-04 08:15

    Call make this way

    make CFLAGS=-Dvar=42
    

    because you do want to override your Makefile's CFLAGS, and not just the environment (which has a lower priority with regard to Makefile variables).

提交回复
热议问题