Click here to Skip to main content
15,851,387 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I would like to define the below interrupt service routine in my C code.

void check_interrupt (uint32_t var1, uint32_t var2) {

I need help with writing a preprocessor command to achieve below replacement:
void isr_tmr_x_tmr_y(void) {
  check_interrupt (x, y);

I tried the below, but its giving compilation errors:

Any possible way of implementing it differently?


What I have tried:

#define DEFINE_TMR_ISR(i, j) \
void isr_tmr_ ## i ## _tmr_ ## j ## (void) {\
  check_tmr_interrupt( ## i ## , ## j ##);\

Updated 10-Dec-22 8:18am
Richard MacCutchan 10-Dec-22 10:03am    
I just tried your code and it works fine. Please use the Improve question link above, and add complete details of what errors you see.
CPallini 10-Dec-22 13:16pm    
You should post here the exact compiler errors, in order to get better help.
Also better detailing your scenario could be helpful.

1 solution

C# doesn't have a #define in the same way as C / C++ does - you can't define macros or substitutions like you can in the older languages. All you can do with #define in C# is cause a symbol to be created for subsequent use in other preprocessor commands (#if, #elif). You cannot use #define symbols in your "normal code" at all.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900