Next: 8.3 Cyclomatic Complexity
Up: 8. SDCC Technical Data
Previous: 8.1.13 Peephole Optimizer
Contents
Index
8.2 ANSI-Compliance
The latest publicly available version of the standard ISO/IEC
9899 - Programming languages - C should be available at: http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899.
Deviations from the compliance:
- in some ports (e. g. mcs51) functions are not reentrant
unless explicitly declared as such or the --stack-auto
command line option is specified.
- structures and unions cannot be assigned
values directly, cannot be passed as function parameters or assigned
to each other and cannot be a return value from
a function, e.g.:
struct s { ... };
struct s s1, s2;
foo()
{
...
s1 = s2 ; /* is invalid in SDCC although allowed
in ANSI */
...
}
struct s foo1 (struct
s parms) /* invalid in SDCC although allowed in ANSI */
{
struct s rets;
...
return rets; /* is invalid in SDCC although allowed
in ANSI */
}
- initialization of structure arrays must be fully braced.
struct s { char x } a[] = {1, 2}; /* invalid
in SDCC */
struct s { char x } a[] = {{1}, {2}}; /* OK
*/
- 'long long' (64 bit integers)
not supported.
- 'double' precision floating point not
supported.
- Old K&R style function declarations are
NOT allowed.
foo(i,j) /* this old style of function declarations */
int i,j; /* is valid in ANSI but not valid in SDCC */
{
...
}
- Some enhancements in C99 are not supported, e.g.:
for (int i=0; i<10; i++) /* is
invalid in SDCC although allowed in C99 */
- Certain words that are valid identifiers in the standard may be reserved
words in SDCC unless the --std-c89
or --std-c99 command line
options are used. These may include (depending on the selected processor):
'at', 'banked', 'bit', 'code', 'critical', 'data', 'eeprom', 'far',
'flash', 'idata', 'interrupt', 'near', 'nonbanked', 'pdata', 'reentrant',
'sbit', 'sfr', 'shadowregs', 'sram', 'using', 'wparam', 'xdata', '_overlay',
'_asm', '_endasm', and '_naked'. The compiler displays a warning
keyword <keyword> is deprecated, use '__<keyword>'
instead in such cases. The warning can be disabled
by using #pragma disable_warning 197
in the source file or -disable-warning 197
command line option. Compliant equivalents of these keywords are always
available in a form that begin with two underscores,
f.e. '__data' instead of 'data' and '__asm' instead of '_asm'.
- Integer promotion of variable arguments is not performed if the argument
is explicitly typecasted unless the --std-c89
or --std-c99 command line
options are used.
void vararg_func (char *str, ...) { str; }
void main (void)
{
char c = 10;
/* argument u is promoted to int before
* passing to function */
vararg_func (%c, c);
/* argument u is not promoted to int,
* it is passed as char to function
* if -std-cXX is not defined;
* is promoted to int before passing
* to function if -std-cXX is defined */
vararg_func (%bc, (char)u);
}
Next: 8.3 Cyclomatic Complexity
Up: 8. SDCC Technical Data
Previous: 8.1.13 Peephole Optimizer
Contents
Index
2012-03-07