the attached is my new attempt to bring binary constants to sdcc. Not that this single feature deserves all this work, but since I started...
The series is compound by 4 patches, plus the documentation updates. A brief description follows.
This is a bugfix patch. Some device libraries were built with --std-c89, but the code included c++ comments (//). Moreover, CFLAGS got lost for PIC14 when building libdev. This patch ensures that libraries using C99 features are actually built using --std-c99, and fixes the PIC14 issue.
This patch makes the preprocessor accept -std=sdcc89 and -std=sdcc99. The effect is limited to enabling the GNU extensions.
Note that to retain some backwards compatibility we should at least enable c++ comments with --std-sdcc89, otherwise a lot of user code will be suddendly broken.
This patch makes sure sdcpp gets called with the correct -sdc=xxx switch
This patch finally implements binary constants. Now these are enabled only with -std-sdccxx and I also propagated the changes to the preprocessor.
One note on this: apparently I'm too dumb to understand why the preprocessor cares about constant parsing, and I haven't been able to actually test the code. Note also that even before this patch the preprocessor parsed binary constants in #if tests, regardless of the -std switch.
For what relates the documentation, the source document was written with a relatively old LyX version (1.4.5). Editing it with the latest version (1.5.6) generates a huge diff, and is probably unwanted anyway due to the bump in the required LyX version.
Since I found that the modifications required by this patch series are small, it's probably more efficient to simply ask somebody else using LyX 1.4 to apply them for me ;-)
The changes are:
In section 1.4, add the following to the list:
* in older versions, the preprocessor was always called with -std=c99 regardless of the --std-xxx setting. This is no longer true, and can cause compilation failures on code built with --std-c89 but using c99 preprocessor features, such as one-line (//) comments.
Insert a new section between 3.4 and 3.5, containing the following:
3.5 Other SDCC language extensions
3.5.1 Binary constants
SDCC supports the use of binary constants, such as 0b01100010. This feature is only enabled when the compiler is invoked using --std-sdccxx.
When invoked with --std-sdccxx, the preprocessor uses the GNU cpp extensions.
This series applies to revision 5202. Please review this carefully before applying since I touched so many parts of the compiler I could very well have done some mistakes.