avr-can-lib icon indicating copy to clipboard operation
avr-can-lib copied to clipboard

Conflicting prototypes for can_init

Open onitake opened this issue 4 years ago • 0 comments

The prototype for can_init in can.h and the source files is not the same, leading to compilation errors when compiling without -fshort-enums.

It would be better to not depend on this compiler flag and simply uint8_t everywhere, but at the very least, both can.h and the driver code should use the same prototype. If avr-can-lib is compiled with -fshort-enums while the application code is not, there will be a mismatch between the data types used for the bitrate argument, leading to problems.

I suggest either replacing the following in can.h:

extern bool can_init(can_bitrate_t bitrate);

with

extern bool can_init(uint8_t bitrate);

or (less preferred) replacing the driver routines

bool at90can_init(uint8_t bitrate)
bool sja1000_init(uint8_t bitrate)

with

bool at90can_init(can_bitrate_t bitrate)
bool sja1000_init(can_bitrate_t bitrate)

Apparently, this was already done for bool mcp2515_init(can_bitrate_t bitrate), so someone must have run into the same problem before.

onitake avatar Jan 10 '21 23:01 onitake