简体   繁体   中英

Command line option to get intermediate c code

I want to see corresponding C code for a cpp file. Is there any option in g++ compiler to get the intermediate C code on compiling the C++ classes??

"I want to see corresponding C code for a cpp file."

There's no such thing like a corresponding C code for a .cpp file (At least not with as tagged in your question). C and C++ are quite different languages, and it's hard (and not necessary) to transform all of modern C++ features to C code.

There was intermediate c code produced by very early implementations of the c++ compiler IIRC.

Nowadays c++ compilers produce either assembly code for the specified machine directly, or provide intermediate code using a backend. I can't find an option to see intermediary produced c code (probably since the compiler doesn't work this way).

The only options I'm aware of are -S to produce intermediary assembly code and -E that results in files after the CPP preprocessor was applied.

The LLVM project seems to provide a backend , that translates anything from the AST parsed with the frontend (eg clang fo c++) to c language.

Well, I didn't try any of these linked search results myself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM