long long
long long
Posted Jun 1, 2007 18:38 UTC (Fri) by vmole (guest, #111)In reply to: long long by giraffedata
Parent article: The return of syslets
This might help: Instant C99.
Yes, typedefs should be testable in the preprocessor. You certainly won't get any argument from me on that point :-) But for stdint, you can check __STDC_VERSION__ to determine whether or not to use your local version or the implmentation provided version.
A key point is that even if you do have to create your own defs, at least name them after the stdint.h types, so that you can later switch without pain and not require other people looking at your code to learn yet another set of typedef names.
Posted Jun 2, 2007 18:56 UTC (Sat)
by giraffedata (guest, #1954)
[Link]
You have to do substantially more work if you want to do that, because you have to make sure nobody else defines the type. If you just do something as simple as checking __STDC_VERSION__, you can't then do a typedef of uint32_t, because it might be defined even though the environment is not totally C99.
And if it's part of an external interface, you surely have no right to define as generic a name as uint32_t. It could easily conflict with header files from other projects that had the same idea.
The "switching" that I think is most important is where someone extracts your code for use in a specific environment where uint32_t is known to be defined. That's why I do all that extra work to be able to use uint32_t (and I don't claim that I've got it right yet) instead of a private name for the same thing.
long long
A key point is that even if you do have to create your own defs, at least name them after the stdint.h types
so that you can later switch without pain