How to debug a preprocessor macro

I recently met this project . The code is mostly written in C, and the API consists of just a few C functions. Unfortunately, the project seems to contain some errors, in particular, I continue to receive “double release or corruption” errors. I am trying to use valgrind and gdb to find out what is wrong. The problem seems to be in the memory allocator. Unfortunately, the first error valgrind occurs in a small preprocessor macro with a length of ~ 400 lines defined in the header. Unfortunately, gdb cannot break the generated code. Stack tracing is also not very useful. Is there any method that can be used to eliminate such errors?

+6
source share
1 answer

The Wandbox.org online compiler has a “CPP” mode, which is very useful for experimenting with the C preprocessor.

See an example here: https://wandbox.org/permlink/tFUsKMIXaQj8hhte

You can do the same offline, gcc -P or cl.exe /E

+1
source

All Articles