简体   繁体   English

命令行选项以获取中间C代码

[英]Command line option to get intermediate c code

I want to see corresponding C code for a cpp file. 我想查看cpp文件的相应C代码。 Is there any option in g++ compiler to get the intermediate C code on compiling the C++ classes?? g ++编译器中是否有任何选项可以获取有关编译C ++类的中间C代码?

"I want to see corresponding C code for a cpp file." “我想查看cpp文件的相应C代码。”

There's no such thing like a corresponding C code for a .cpp file (At least not with as tagged in your question). 没有像.cpp文件相应C代码这样的东西(至少与您问题中标记的一样)。 C and C++ are quite different languages, and it's hard (and not necessary) to transform all of modern C++ features to C code. C和C ++是完全不同的语言,很难(也没有必要)将所有现代C ++功能转换为C代码。

There was intermediate c code produced by very early implementations of the c++ compiler IIRC. c ++编译器IIRC的早期实现产生了中​​间的c代码。

Nowadays c++ compilers produce either assembly code for the specified machine directly, or provide intermediate code using a backend. 如今,c ++编译器直接为指定的机器生成汇编代码,或者使用后端提供中间代码。 I can't find an option to see intermediary produced c code (probably since the compiler doesn't work this way). 我找不到看到中介产生的C代码的选项(可能是因为编译器无法以这种方式工作)。

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. 我知道的唯一选项是-S生成中间汇编代码,以及-E在应用CPP预处理程序后生成文件。

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. LLVM项目似乎提供了一个后端 ,它将使用前端解析的AST(例如clang fo c ++)中的任何内容转换为c语言。

Well, I didn't try any of these linked search results myself. 好吧,我自己没有尝试任何这些链接的搜索结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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