Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define C++ preprocessor variable in Makefile

Tags:

c++

makefile

I have a C++ preprocessor written like this:

  #ifdef cpp_variable    //x+y;   #endif 

Can anyone tell me how to define this in Makefile.

like image 788
Joel Avatar asked Mar 06 '11 22:03

Joel


People also ask

What is macro in makefile?

A macro is a variable that MAKE expands into a string whenever MAKE encounters the macro in a makefile. For example, you can define a macro called LIBNAME , which represents the string mylib. lib . To do this, type the line LIBNAME = mylib. lib at the beginning of your makefile.

What is Cppflags?

CPPFLAGS. CPPFLAGS is used to pass extra flags to the C preprocessor. These flags are also used by any programs that use the C preprocessor, including the C, C++, and Fortran compilers. You do not need to explicitly call the C preprocessor.


1 Answers

This is compiler specific.

GCC uses -Dcpp_variable=VALUE or just -Dcpp_variable

Microsoft's compilers use /D

like image 189
Reed Copsey Avatar answered Sep 18 '22 14:09

Reed Copsey