#966 PIC16: Clash between bits in signal.h and pic18fXXXX.h

Peter Onion

It is impossible to write code to clear TMR2IF in the
TMR2 signal handler due to multiple use of the name
"TMR2IF". It is defined as a bit in the PIR1 structure
in (for example) pic18f458.h

extern __sfr __at (0xf9e) PIR1;
typedef union {
struct {
unsigned TMR1IF:1;
unsigned TMR2IF:1;
unsigned CCP1IF:1;
unsigned SSPIF:1;
unsigned TXIF:1;
unsigned RCIF:1;
unsigned ADIF:1;
unsigned PSPIF:1;
} __PIR1bits_t;

extern volatile __PIR1bits_t __at (0xf9e) PIR1bits;

AND it is defined in signal.h

#define TMR1IF 0x0
#define TMR2IF 0x1
#define CCP1IF 0x2
#define SSPIF 0x3
#define TXIF 0x4
#define RCIF 0x5
#define ADIF 0x6
#define PSPIF 0x7

The preprocessor gets there first and so when you write

PIR1bits.TMR2IF = 0;

the compiler gets
PIR1bits.0x1 = 0;
and gives the error
: syntax error: token -> '0x1' ; column 11

My solution is to prefix the symbols in signal.h with SIG_



  • Raphael Neider

    Raphael Neider - 2005-08-07
    • labels: --> pic16 target
    • milestone: --> fixed
    • assigned_to: nobody --> tecodev
    • status: open --> closed-accepted
  • Raphael Neider

    Raphael Neider - 2005-08-07

    Logged In: YES

    Fixed in SDCC 2.5.2 #1083.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks