Deviations from ansi c, D in the, Prototype of main – Zilog ZUSBOPTS User Manual
Page 223

UM017105-0511
ANSI Standard Compliance
Zilog Developer Studio II – ZNEO™
User Manual
195
mentation means that the compiler must contain, at least, a specific subset of the full ANSI
C features. This subset consists of those basic language features appropriate to embedded
applications. Specifically the list of required header files and associated library functions
is minimal, namely <
float.h
>, <
limits.h
>, <
stdarg.h
>, and <
stddef.h
>. A free-
standing implementation is allowed to additionally support all or parts of other standard
header files but is not required to. The ZNEO C-Compiler, for example, supports a number
of additional headers from the standard library, as specified in the
Required for Freestanding Implementation
A conforming implementation (that is, compiler) is allowed to provide extensions, as long
as they do not alter the behavior of any program that uses only the standard features of the
language. The Zilog ZNEO C-Compiler uses this concept to provide language extensions
that are useful for developing embedded applications and for making efficient use of the
resources of the ZNEO CPU. These extensions are described in the
Deviations from ANSI C
The differences between the Zilog ZNEO C-Compiler and the freestanding implementa-
tion of the ANSI C Standard consist of both extensions to the ANSI standard and devia-
tions from the behavior described by the standard. The extensions to the ANSI standard
are explained in
There are a small number of areas in which the ZNEO C-Compiler does not behave as
specified by the Standard. These areas are described in the following sections.
Prototype of Main
As per ANSI C, in a freestanding environment, the name and type of the function called at
program startup are implementation defined. Also, the effect of program termination is
implementation defined.
For compatibility with hosted applications, the ZNEO C-Compiler uses
main()
as the
function called at program startup. Because the ZNEO compiler provides a freestanding
execution environment, there are a few differences in the syntax for
main()
. The most
important of these is that, in a typical small embedded application,
main()
never executes
a return as there is no operating system for a value to be returned to and is also not
intended to terminate. If
main()
does terminate, and the standard Zilog ZNEO C start-up
module is in use, control simply goes to the statement:
_exit:
JP _exit
For this reason, in the ZNEO C-Compiler,
main()
must be of type
void
; any returned
value is ignored. Also,
main()
is not passed any arguments. The following example pres-
ents the prototype for
main()
:
void main (void);