#1762 [PIC16] Inconsistent declarations of USTATbits

open
nobody
PIC16
5
2013-07-16
2011-02-20
Goofy
No

in pic18f4450.h, USTATbits are defined as:

228 extern __sfr __at (0xF6C) USTAT;
229 typedef union {
230 struct {
231 unsigned : 1;
232 unsigned PPBI : 1;
233 unsigned DIR : 1;
234 unsigned ENDP0 : 1;
235 unsigned ENDP1 : 1;
236 unsigned ENDP2 : 1;
237 unsigned ENDP3 : 1;
238 unsigned : 1;
239 };
240 } __USTATbits_t;
241 extern volatile __USTATbits_t __at (0xF6C) USTATbits;

and in pic18f2455.h:

147 extern __sfr __at (0xF6C) USTAT;
148 typedef union {
149 struct {
150 unsigned : 1;
151 unsigned PPBI : 1;
152 unsigned DIR : 1;
153 unsigned ENDP : 4;
154 unsigned : 1;
155 };
156 } __USTAT_t;
157 extern volatile __USTAT_t __at (0xF6C) USTATbits;

The second one should be preferred, as ENDP is most of the time used as an index.
Moreover, it is important to keep consistent definitions to make easier writing of portable code.
Other header files should also be checked and fixed if required.

Discussion

  • Goofy
    Goofy
    2011-02-20

    • summary: [PIC16] Inconsistency declarations of USTATbits --> [PIC16] Inconsistent declarations of USTATbits
     
  • Goofy
    Goofy
    2011-02-20

    Other headers that should be fixed:
    pic18f14k50.h
    pic18f46j50.h
    pic18f67j50.h
    pic18f87j50.h

     
    • Category: --> PIC16