Next: 8.3 Cyclomatic Complexity
Up: 8. SDCC Technical Data
Previous: 8.1.13 Peephole Optimizer
Contents
Index
8.2 ANSI-Compliance
The latest publically 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:
- 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 */
{
...
}
- Most enhancements in C99 are not supported, e.g.:
for (int i=0; i<10; i++) /* is
invalid in SDCC although allowed in C99 */
- But some have been added recently in SDCC 2.7.0. They must be considered
alpha quality however.
inline int
increment (int a) { return a+1; } /* inlines the increment without
function call overhead */
int * restrict
p; /* accepted but ignored */
- 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'. Compliant equivalents of these
keywords are always available in a form that begin with two underscores,
f.e. '__data' instead of 'data'.
- Integer promotion of variable arguments is not performed if the argument
is explicitly taypecasted 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
2008-12-05