-
-
Notifications
You must be signed in to change notification settings - Fork 14
Differences from C90
picoC is a tiny C language, not a complete implementation of C90. It doesn't aim to implement every single feature of C90 but it does aim to be close enough that most programs will run without modification.
picoC also has scripting abilities which enhance it beyond what C90 offers.
There is no true preprocessor in picoC. The most popular preprocessor features are implemented in a slightly limited way.
define macros are implemented but have some limitations. They can only be used as part of expressions and operate a bit like functions. Since they're used in expressions they must result in a value.
The conditional compilation operators are implemented, but have some limitations. The operator "defined()" is not implemented. These operators can only be used at statement boundaries.
include is supported however the level of support depends on the specific port of picoC on your platform. Linux/UNIX and cygwin support #include fully.
This style of function declaration is supported:
int my_function(char param1, int param2, char *param3) { ... }
The old "K&R" form of function declaration is not supported.
A few macros are pre-defined:
-
picoC_VERSION - gives the picoC version as a string eg.
"v2.1 beta r524"
- LITTLE_ENDIAN - is 1 on little-endian architectures or 0 on big-endian architectures
- BIG_ENDIAN - is 1 on big-endian architectures or 0 on little-endian architectures
Pointers to functions should be supported. If any issues are encountered, bring them up on the PKSM repository.
Many of the storage classes in C90 really only have meaning in a compiler so they're not implemented in picoC. This includes: static, extern, volatile, register and auto. They're recognised but currently ignored.
Structs and unions can only be defined globally. It's not possible to define them within the scope of a function.
Bitfields in structs are not supported.
Because picoC is an interpreter (and not a compiler) libraries must be linked with picoC itself. Also a glue module must be written to interface to picoC. This is the same as other interpreters like python.
If you're looking for an example check the interface to the C standard library time functions in cstdlib/time.c.
The goto statement is implemented, but only supports forward gotos, not backward. The rationale for this is that backward gotos are not necessary for any "legitimate" use of goto.
Some discussion on this topic:
Passing arrays as pointers to variadic argument functions seems to be interestingly broken. The cause of this is currently unknown, but as a workaround, &array[0]
may be passed instead
Enjoy using PKSM? Consider supporting FlagBrew on Patreon