Macro expansion and Assembly code
来源:互联网 发布:淘宝无线宝推广 编辑:程序博客网 时间:2024/06/06 17:22
We know that compiler will expand macros before it actually compiles the code. Sometimes it's useful if we can view the result of the expansion, especially when we use macro to implement some functions. Here is how:
Microsoft C++ compiler:
cl.exe source.cpp /E (preprocess to standard output)
cl.exe source.cpp /P (preprocess to file)
gcc:
gcc source.cpp -E (short for expand)
We can also peek into the assembly code generated by the compiler. With the following options, the compiler will generate a source.s file containing the assembly code in current directory.
Microsoft C++ compiler:
cl.exe source.cpp /FAs
gcc:
gcc source.cpp -S
References:
GCC options you should know
Macro Expansion Algorithm
Compiler Options (MSDN)
Microsoft C++ compiler:
cl.exe source.cpp /E (preprocess to standard output)
cl.exe source.cpp /P (preprocess to file)
gcc:
gcc source.cpp -E (short for expand)
We can also peek into the assembly code generated by the compiler. With the following options, the compiler will generate a source.s file containing the assembly code in current directory.
Microsoft C++ compiler:
cl.exe source.cpp /FAs
gcc:
gcc source.cpp -S
References:
GCC options you should know
Macro Expansion Algorithm
Compiler Options (MSDN)
- Macro expansion and Assembly code
- The Macro Expansion Process (Forwarded)
- Implementing a Recursive Procedure with IA32 and Y86 Assembly Code
- Writing and Optimizing ARM Assembly Code 《ARM...》Chapter-6
- offsetof macro test code
- 程序中出现unexpected end of file in macro expansion
- Set&Get and MACRO
- the macro # and ## (typing...)
- MACHINE_START and MACHINE_END Macro define
- difference with Macro and Template
- Assembly x64 Intro - Register Macro Define from OpenH264
- NameSpace and Assembly
- Assembly and loaders
- ffmpeg source code analyse - macro - MATCH_PER_TYPE_OPT
- Pandaboard data-acquisition and FPGA expansion
- macro
- macro
- macro
- View memory usage
- A great book for asp.net mvc
- Use VI command in bash
- Minimize Code Explosion of Generic Type
- GoAhead Web Server Hang
- Macro expansion and Assembly code
- Detect Stack Corruption
- Fix bugs with core dump
- Extensive usage of Make
- Enable SSL in goAhead web server
- Product quality issue
- Living in Huangpu river
- posting failed?
- 统计文件中出现的keyword的次数