I recently came across this project. The code is largely written in C and the API consists of just a few C functions. Unfortunately the project seems to contain some bugs, in particular I keep getting "double free 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 valgrind error occurs in some ~400 line long preprocessor macro defined in a header. Unfortunately gdb can't break on the generated code. The stack trace is not very useful either. Is there any technique which can be used to deal with these kind of errors?
Open up a source file from your manage project in Visual Studio and set a breakpoint on a line. Start debugging in Visual Studio by pressing F5. In Excel, open up your worksheet and start debugging your VBA code using Excel's debugger.
If there is a current stack frame, GDB uses the macros in scope at that frame's source code line. Otherwise, GDB uses the macros in scope at the current listing location; see List. Whenever GDB evaluates an expression, it always expands any macro invocations present in the expression.
Preprocessor Macros are directives executed by the compiler, so they're not part of Objective C. We've used them many times before with the #import statement. But to stay with our Lite and Pro example: you can use a Preprocessor if/then statement to check which version is being compiled.
The online compiler Wandbox.org has a "CPP" mode that is very useful to experiment with the C preprocessor.
See an example here: https://wandbox.org/permlink/tFUsKMIXaQj8hhte
You can do the same thing offline, with gcc -P
or cl.exe /E
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With