Hi,

Can anyone provide some examples or materials explaining ANSI and Non ANSI C Standards?
Need some examples for non Ansi C Stanadard.

Thanks in advance,

regards,
senche

Well the ANSI C standard basically tries to encourage better program design so that code produced is nice and portable.
You could just do a basic google search for ANSI C and get a ton of information. The first hit I got was this.

>Need some examples for non Ansi C Stanadard.
When someone says something like "Non-ANSI", they usually mean pre-standard C (often the K&R variant). If you want to be picky, the current C standard is non-ANSI because ANSI no longer controls the C standard, ISO does.

If you want examples, this is a good read. The problem with such examples is prior to standardization (and the primary reason for standardization), each compiler implemented a slightly different dialect. Further, many of the common practices were kept in the standard, which means you can pull out examples of pre-standard C that compile and run perfectly on a C90 compiler. For example:

#include <stdio.h>

main(argc, argv)
    int argc;
    char **argv;
{
    char **p = argv;

    while (*p != NULL)
        puts(*p++);

    return 0;
}

K&R function definitions are the most noticeable difference between standard and pre-standard C (even though they still work up to C99).

Not mentioned here is compiler extensions. They are special keywords or commands, usually prefixed with double underscores, which is highly compiler specific. Using even one of these features automatically makes your code non ANSI-C compliant, unless of course you surround such code within preprocessors which block that kind of code in "ANSI C compliance" mode.

Anyhow, here are some examples for the gcc: http://oreilly.com/linux/excerpts/9780596009588/gcc-extensions-to-the-c-language.html

Edited 6 Years Ago by N1GHTS: n/a

This article has been dead for over six months. Start a new discussion instead.