Hansi, > Am Mittwoch, den 31.12.2008, 17:43 +0100 schrieb Maarten Brock: > > The headers could be included and I'm glad you already used > > compiler.h. But I do not like anything I see in uctypes.h. NULL, > > bool and the int's are all already defined in stdlib.h, stdbool.h > > and stdint.h. Please use those. > > Using 'bool' as defined by stdbool.h as a bit makes problems when using > functions with a bool return type and making a pointer to such a > function. > > typedef bool (*BoolReturnFunc_t)(); > > bool TestFunc() { > return true > } > > void test() { > BoolReturnFunc_t FuncPtr; > FuncPtr = &TestFunc; // <-- error > } > > gives the error > error 35: '&' illegal operand , address of bit variable > > Probably this is just a bug report. I've modified all such functions to > return an uint8_t. For all others I use bool and stdbool.h.
I agree that this is a bug, but it can easily be circumvented by removing '&'. You don't need to take the address of a function to turn it into a function pointer. E.g. FuncPtr = TestFunc; //should give no error > I've also removed uctypes.h and use stdint.h everywhere. Thanks for the > hint that all this is already prepared. :-) > > > And when compiling with --std-c89 you cannot use // comments nor > > 'xdata'. Please use /* */ and __xdata instead. > > Is the possibility to compile with --std-c89 mandatory? > > I tried to compile with --std-c89 and it gives the warning > warning 187: ISO C90 does not support flexible array members > for an "open" array element of > typedef struct { > ... > int Field[]; > } name; > How can I get rid of this warning? You can either use 'int Field[1];' or insert a pragma to ignore the warning. But if you think you need C99 functionality and document it in the comments I doubt it would be a problem. > Everything else in the library I've changed to be --std-c89 compliant. > > > Personally, I am totally against function implementations in header > > files unless 'inline'd. But inline again is C99 only. > > I'm too against implementations in .h files. Where did you find those? Huh? All functions in tusb3210.h are definitions! To make them prototypes everything between the curly braces {} should be removed and the braces themselves too. But I suggest to remove them completely from this file. > > Finally, are you sure the TUSB is completely 8052 compatible? > > Otherwise I'd prefer not to include 8052.h and copy the relevant > > portions only. > > Yes, the datasheet says: > > * Integrated 8052 Microcontroller With: > - 256 × 8 RAM for Internal Data > - 8K × 8 RAM Code Space Available for Downloadable Firmware From > Host > or I2C Port. > - 512 × 8 Shared RAM Used for Data Buffers and Endpoint Descriptor > Blocks (EDB) > - Four 8052 GPIO Ports, Ports 0,1, 2, and 3 > - Master I2C Controller for External Slave Device Access > - Watchdog Timer > > So it is a real 8052 and not an 8051. But have you verified every sfr and every bit in it? Is every peripheral of the 8052 present in this mcu and not missing any function? Nor enhanced? This summation does not convince me. Maarten ------------------------------------------------------------------------------ Check out the new SourceForge.net Marketplace. It is the best place to buy or sell services for just about anything Open Source. http://p.sf.net/sfu/Xq1LFB _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user