When compiling using --std-sdccxx, sdcc defines a macro SDCC defined the conctenation of the version numbers (major, minor, p).
The macro name makes is incompatible with the C standard. And comparing it as an integer is problematic when any version number is above 9.
It should thus be deprecated, and replacements introduced.
I suggest:
__SDCC_VERSION, defined to MAJOR_VERSION.MINOR_VERSION
and
__SDCC_VERSION_MAJOR
__SDCC_VERSION_MINOR
__SDCC_VERSION_P
Philipp
http://sourceforge.net/p/predef/wiki/Compilers/ has a huge collection.
The GCC scheme seems not bad:)
Greetings,
I like Borland C style,
Because I thought int can be more efficient than float on 8-bit MCUs.
Last edit: Maarten Brock 2015-06-29
I assumed that users would mostly use the version at preprocessing time, so float vs. int wouldn't matter.
But now I think we should provide just the macros for major, minor and p version, and users can make their own version macro, float or int from it as they like.
Philipp
Since I don't know how useful the patch version is, I left it out for now. Macros for major and minor version are in as of revision [r9261].
Philipp
Last edit: Maarten Brock 2015-06-29
Hi Philip,
I feel this might not have been discussed thoroughly enough.
The GCC macros (as per the link given above) are
They seem very reasonable to me and allow things like:
or:
(so it can easily be compared/printed as integer. In the second example even without using integer division for the deeply embedded systems)
Why not follow the GCC scheme and use
As we use GCC's precompiler using GCC's convention seems a natural choice to me.
The PATCHLEVEL is useful to have even if there is no immediate use for it.
If e.g. a there's a bug with (or below) a specific patch level of SDCC which only surfaces later then a #warning (or a workaround) can be used without having to test #ifdef __SDCC_PATCHLEVEL__ first. (Without patchlevel the user could have to wait about a year until the ).
Greetings,
Frieder
(hopefully Sourceforge doesn't garble the strings. If it does: my proposal is to exchange "GNUC" by "SDCC" in the Macros within the link given in my first post.)
Last edit: Maarten Brock 2015-06-29
I don't like that the names of the gcc macros do not clearly communicate what they are. And I don't like the name of the major version macro being inconsistent with the names of the other two.
I don't mind adding another macro for the patchlevel. That should allow everything that the gcc macros do.
Philipp
Diff:
I suggest to add __SDCC_VERSION_PATCH as well.
Implemented in revision #9273.
Philipp
thanks, closed for me too.
Buffer sizes with 20 bytes are a little on the short side. Please apply something like the appended patch.
On the other hand, 32 seems plenty for now. I increased it to 32 in revision #9274.
Philipp