Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM equivalent of gcc -D macro definition on commandline

I am looking for LLVM (or clang) equivalent of gcc's -D flag which enables macro definition at commandline.

Any pointers would be great.

like image 201
shrm Avatar asked Mar 13 '13 12:03

shrm


People also ask

Does LLVM use GCC?

How Is LLVM Different From GCC? LLVM and the GNU Compiler Collection (GCC) are both compilers. The difference is that GCC supports a number of programming languages while LLVM isn't a compiler for any given language. LLVM is a framework to generate object code from any kind of source code.

Can I use Clang instead of GCC?

You can use Clang instead of GCC as a compiler for any package by overriding stdenv , which contains the compilation toolchain, with: stdenv = pkgs.

What is Clang cc1?

The -cc1 argument indicates that the compiler front-end is to be used, and not the driver. The clang -cc1 functionality implements the core compiler functionality. So, simply speaking. If you do not give -cc1 then you can expect the "look&feel" of standard GCC.

What is Clang option?

The Clang Compiler is an open-source compiler for the C family of programming languages, aiming to be the best in class implementation of these languages. Clang builds on the LLVM optimizer and code generator, allowing it to provide high-quality optimization and code generation support for many targets.


1 Answers

From clang --cc1 --help:

...
-D <macro>=<value>      Define <macro> to <value> (or 1 if <value> omitted)
...

As a rule of thumb, assume that Clang emulates GCC, unless proven otherwise!

like image 135
Oliver Charlesworth Avatar answered Sep 18 '22 03:09

Oliver Charlesworth