do {…} while (0) in macros


If you are a C programmer, you must be familiar with macros. They are powerful and can help you ease your work if used correctly. However, if you don’t define macros carefully, they may bite you and drive you crazy. In many C programs, you may see a special macro definition which may seem not so straightforward. Here is one example:

Continue reading

Avoid using a macro if you can use a simple function

The fragment is taken from ReactOS project. The code contains an error that analyzer diagnoses in the following way: V640 The code’s operational logic does not correspond with its formatting. The second statement will always be executed. It is possible that curly brackets are missing.

Continue reading