cwarningscompiler-warningsavr

type of 'USART0_RX_vect' defaults to 'int' [enabled by default]


Learning AVR C programming i end up getting a warning from

int ISR(USART0_RX_vect) {
    // blah blah blah...
    return 0;
} 
//Warning   1   type of 'USART0_RX_vect' defaults to 'int' [enabled by default]

Why is this warning appearing and what actions are required to remove it?


Solution

  • From what I can tell your syntax is just wrong. ISR is a macro that simplifies the definition of an interrupt handler routine. ISR resolves to an __attribute__ decorated function which signature already specifies the return type void.

    USART0_RX_vect will be resolved to something like __vector_18 (ATMEGA128).

    Something like this will be the define-substituted result:

    void __vector_18 (void) __attribute__ ((signal,__INTR_ATTRS));
    void __vector_18 (void) {
        // your code would appear here
    }
    

    So just omit the return type since is and has to be void.