How to understand big C / C ++ code full of macros?

Possible duplicate:
C / C ++ source file after preprocessing

The other day, I was assigned the task of fixing a mistake in a large C / C ++ project developed for VC ++ 8. The problem is that this code is really filled with nested macros. What is the best way to understand this code? Any suggestion is welcome.

+4
source share
2 answers

Using the /E compiler line option, the assembly will output all the preprocessor output to the standard version. This file will include all macros extended along with all included extended built-in macros. You will need to find the best way to add this flag depending on how you build the project. With the exit, you can better see that the macro expands too, but it can still be difficult to track the output to which the macro expanded it. However, you must be able to understand this. Link for command line options for VS8.0 compiler .

As stated in the comments, this is a duplicate, and here is the best answer: fooobar.com/questions/34399 / ...

+3
source

I think you first need to understand what macros do, and then try to understand what code does after expanding macros. We hope that each macro or a small set of macros makes some sense that you can find from the definitions and / or comments.

While you can run the code through the preprocessor, this usually gives you a pretty undifferentiated mass (no comment), which is probably harder to understand.

+3
source

Source: https://habr.com/ru/post/1386603/


All Articles