Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a breakpoint in a macro in Visual Studio

Is there a way to set a breakpoint for C code in Visual Studio inside a #define? When I set the breakpoint it isn't reached, and the rest code continues to be executed. For example:

#define YY_USER_ACTION sn_yylloc.first_line = sn_yylloc.last_line =sn_yylineno; \
sn_yylloc.first_column = sn_yycolumn; \
sn_yylloc.last_column = sn_yycolumn + sn_yyleng -1; \
sn_yycolumn += sn_yyleng;

The code is a lexer generated by Flex, but that's really of no importance.

like image 240
Lieven Cardoen Avatar asked Dec 07 '25 21:12

Lieven Cardoen


1 Answers

This #define is being expanded by the preprocessor before compilation. What you could do is try to run with the Visual Studio debugger with this code instead of the original code (read this question about getting your hands on the preprocessed code).

like image 158
NiRR Avatar answered Dec 09 '25 11:12

NiRR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!