Cannot use #if with interrupt vectors

Hi,
I wanted to use preprocessing macros to easily change which interrupt is used for my detector. There is minimal (non)working example:

#define DetectorInterrupt INT0_vect

void setup() {
  #if DetectorInterrupt==PCINT0_vect
    #error running wrong code
  #else
  #endif
}

void loop {}

If I use "5==6" as the condition no error. "DetectorInterrupt==18" also cause no error. But comparing any two interrupt vectors returns "true" and the wrong branch is compiled. Why?

Does INT0_vect == PCINT0_vect ?

I found likely cause.
At time of compile of this part of code PCINT0_vect expands to __vector_2 (on Digispark) which is undefined (yet). Not even adding ISR(PCINT0_vect) makes the interrupt vector defined. So comparing any two interrupt vectors ends in expanding undefined macros (__vector_x) which is expanded to 0.
I will have to find some workaround :frowning:

Try XXX_vect_num instead of XXX_vect.

But that still doesn't answer larryd's question. Why are you checking two different macros? INT0_vect and PCINT0_vect

septillion:
But that still doesn't answer larryd's question.

I did. INT0==__vector_1==0==__vector_2==PCINT0. "Defining" the interrupt vectors by ISR() makes no difference (meaning it is not because both are undefined and point to the same "bad interrupt vector"). Also I tried to check them by #ifdef. PCINT0, INT0 are defined while __vector_1 and __vector_2 are not.

septillion:
Why are you checking two different macros? INT0_vect and PCINT0_vect

I want to use Digispark for debugging part of the code and then use it on ATTiny13A. AFAIK Digispark needs Pin Change interrupt for USB functionality so I must use External Interrupt. But I will use both PWM pins on the Tiny and so I cannot use the External interrupt (they share pin). So I wanted to define used interrupt by macro and when it matters (when setting interrupts in the code) check which one is in use.
I will probably do it this way:

#define PCUSED 0
#if PCUSED
  #define DetectorInterrupt PCINT0_vect //for ATTint13A
#else
  #define DetectorInterrupt INT0_vect   //for Digispark
#endif
ISR(DetectorInterrupt) ...

and test the PCUSED value.

oqibidipo:
Try XXX_vect_num instead of XXX_vect.

If I use ISR(XXX_vect_num) {...} will I get the same result as ISR(XXX_vect) {...}?

Smajdalf:
If I use ISR(XXX_vect_num) {...} will I get the same result as ISR(XXX_vect) {...}?

#define DetectorInterrupt INT0_vect_num

void setup() {
  #if DetectorInterrupt==PCINT0_vect_num
    #error running wrong code
  #else
  #endif
  Serial.begin(115200);
  Serial.println(PCINT0_vect_num);
}

void loop(){}
Sketch uses 1694 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 188 bytes (9%) of dynamic memory, leaving 1860 bytes for local variables. Maximum is 2048 bytes.

Smajdalf:
If I use ISR(XXX_vect_num) {...} will I get the same result as ISR(XXX_vect) {...}?

The right answer is NO: argument for ISR must be XXX_vect, XXX_vect_num does not work.