[Fx2lib-devel] fx2lib & stdbool.h
Status: Beta
Brought to you by:
mulicheng
From: Chris M. <fx...@m3...> - 2011-03-13 19:21:26
|
I discovered an irritating problem. The fx2types.h header defines BOOL thus: typedef unsigned char BOOL; ...whereas stdbool.h (sdcc 2.9.0) defines it: #define BOOL __bit This difference is crucial because it affects how the ABI returns BOOL from function calls. In the former case BOOL is returned as a 0x00 or 0x01 in DPL (an 8-bit register) whereas in the latter case it is returned in the carry flag. Since stdbool’s definition of BOOL is a preprocessor macro, merely including stdbool.h in the file defining handle_vendorcommand() is enough to introduce subtle bugs where fx2lib ignores the “actual” return value (in the carry flag) and instead assumes the return value is in the DPL register, whose value will at that point be garbage. Now that I know about it, I can easily work around this mismatch, but switching fx2lib to use stdbool.h seems like a good idea. It’s a trivial change (about five lines changed), but my testing (though extensive) is not exhaustive. Before I do the work to make a clone and send a pull request, what are my chances of getting the change in? Chris |