Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the equivalent of `cpp -dD` for clang?

Tags:

If I want to find out what implicit preprocessor defines gcc gives me, I can type echo "" | cpp -dD. Does anyone know what the equivalent for clang is?

like image 590
Ted Middleton Avatar asked Dec 28 '10 19:12

Ted Middleton


People also ask

What version of C++ does Clang use?

By default, Clang builds C++ code according to the C++14 standard. You can use Clang in C++14 mode with the -std=c++14 option (use -std=c++1y in Clang 3.4 and earlier).

What is Clang CPP?

clang is a C, C++, and Objective-C compiler which encompasses preprocessing, parsing, optimization, code generation, assembly, and linking. Depending on which high-level mode setting is passed, Clang will stop before doing a full link.

Is Clang the same as clang ++?

The only difference between the two is that clang links against only the C standard library if it performs a link, whereas clang++ links against both the C++ and C standard libraries.

Should I use clang ++ or g ++?

Clang is much faster and uses far less memory than GCC. Clang aims to provide extremely clear and concise diagnostics (error and warning messages), and includes support for expressive diagnostics. GCC's warnings are sometimes acceptable, but are often confusing and it does not support expressive diagnostics.


2 Answers

clang -dM -E - < /dev/null

will list all the preprocessor definitions for clang.

like image 165
ismail Avatar answered Oct 11 '22 11:10

ismail


clang "dumping processor state" options are defined here. The option you are looking for is -dM, so you'll run:

clang -dM -E -

To trigger execution, you then need to terminate the manual input:

  • For Windows: Ctrl-Z Enter
  • For Unix: Ctrl-D

Otherwise, directly execute:

  • For Windows: clang -dM -E - < NUL
  • For Unix: clang -dM -E - < /dev/null
like image 41
Antonio Avatar answered Oct 11 '22 11:10

Antonio