OAR

RTEMS GNU Tools On-Line Library


ANSI C

PREV UP NEXT Bookshelf GNU Coding Standards

3.3: ANSI C and pre-ANSI C

Do not ever use the ``trigraph'' feature of ANSI C.

ANSI C is widespread enough now that it is ok to write new programs that use ANSI C features (and therefore will not work in non-ANSI compilers). And if a program is already written in ANSI C, there's no need to convert it to support non-ANSI compilers.

However, it is easy to support non-ANSI compilers in most programs, so you might still consider doing so when you write a program. Instead of writing function definitions in ANSI prototype form,

int
foo (int x, int y)
...

write the definition in pre-ANSI style like this,

int
foo (x, y)
     int x, y;
...

and use a separate declaration to specify the argument prototype:

int foo (int, int);

You need such a declaration anyway, in a header file, to get the benefit of ANSI C prototypes in all the files where the function is called. And once you have it, you lose nothing by writing the function definition in the pre-ANSI style.

If you don't know non-ANSI C, there's no need to learn it; just write in ANSI C.


PREV UP NEXT Bookshelf GNU Coding Standards

Packaging copyright © 1988-2000 OAR Corporation
Context copyright by each document's author. See Free Software Foundation for information.