- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you really need all those little u's (unsigned designators) everywhere?
I'm very fluent in visually reading "hexadecimal" data. As such, all those little u's are really annoying.
If the array is already type casted with uint8, do we still need to add the u suffix to the data entries?
This slows me down significantly in my coding efficiency.
See below for an example.
--------------------------- too many u's --------------------------------------
/* I2C Read service UUID*/
const uint8 I2CReadUUID[16] = {
0x00u, 0x00u, 0xFBu, 0x34u, 0x9Bu, 0x5Fu, 0x80u, 0x00u, \
0x00u, 0x80u, 0x00u, 0x10u, 0x01u, 0x00u, 0x0Au, 0x00u \
};
---------------------- BETTER and more READABLE ----------------------
/* I2C Read service UUID*/
const uint8 I2CReadUUID[16] = {
0x00, 0x00, 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, \
0x00, 0x80, 0x00, 0x10, 0x01, 0x00, 0x0A, 0x00 \
};
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a coding standard named "MISRA" that tells some stupid things are required. Not only the "u"s are part of that, what annoys me is that comments using double slashes are not allowed. Companies like Cypress are bound to confirm to MISRA rules.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a coding standard named "MISRA" that tells some stupid things are required. Not only the "u"s are part of that, what annoys me is that comments using double slashes are not allowed. Companies like Cypress are bound to confirm to MISRA rules.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ahhh...
Well.. I'M NOT adhering To MISRA standards... you can count me out of that!
But the question remains.. can I eliminate the "u"s and freely use double slash comments without erroneous results if I so choose to do so?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Keep calm, relax! As long as the compiler does not quail over bad unreadable code you may use anything or leave it out. You probably need the "u" in the following case:
int i; //That's signed
i = 0x80; // is that a -128 or a 127 ?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm good with the u's when necessary.
Thanks for the pointers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're always welcome!
Bob