Thread: C89 and C99

  1. #1
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472

    C89 and C99

    What are the major differences between C98 and C99? the ones i know so far are :

    C89 :
    - Only /* */ comments are allowed
    - Variables must be declared at the top of each function.

    C99 :
    - Both /* */ and // comments are allowed.
    - Variables can be declared any where within a function.
    - 5 new keywords :
    restrict _Bool _Complex _Imaginary inline


    are there more differences? and what standard does C++ use?
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    http://david.tribble.com/text/cdiffs.htm

    From the C99 Foreward:
    This second edition cancels and replaces the first edition, ISO/IEC 9899:1990, as amended and corrected by ISO/IEC 9899/COR1:1994, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2:1996. Major changes from the previous edition include:
    — restricted character set support via digraphs and <iso646.h> (originally specified in AMD1)
    — wide character library support in <wchar.h> and <wctype.h> (originally specified in AMD1)
    — more precise aliasing rules via effective type
    — restricted pointers
    — variable-length arrays
    — flexible array members
    — static and type qualifiers in parameter array declarators
    — complex (and imaginary) support in <complex.h>
    — type-generic math macros in <tgmath.h>
    — the long long int type and library functions
    — increased minimum translation limits
    — additional floating-point characteristics in <float.h>
    — remove implicit int
    — reliable integer division
    — universal character names (\u and \U)
    — extended identifiers
    — hexadecimal floating-point constants and %a and %A printf/scanf conversion specifiers
    — compound literals
    — designated initializers
    — // comments
    — extended integer types and library functions in <inttypes.h> and <stdint.h>
    — remove implicit function declaration
    — preprocessor arithmetic done in intmax_t/uintmax_t
    — mixed declarations and code
    — new block scopes for selection and iteration statements
    — integer constant type rules
    — integer promotion rules
    — macros with a variable number of arguments
    — the vscanf family of functions in <stdio.h> and <wchar.h>
    — additional math library functions in <math.h>
    — floating-point environment access in <fenv.h>
    — IEC 60559 (also known as IEC 559 or IEEE arithmetic) support
    — trailing comma allowed in enum declaration
    — %lf conversion specifier allowed in printf
    — inline functions
    — the snprintf family of functions in <stdio.h>
    — boolean type in <stdbool.h>
    — idempotent type qualifiers
    — empty macro arguments
    — new struct type compatibility rules (tag compatibility)
    — additional predefined macro names
    — _Pragma preprocessing operator
    — standard pragmas
    — _ _func_ _ predefined identifier
    — VA_COPY macro
    — additional strftime conversion specifiers
    — LIA compatibility annex
    — deprecate ungetc at the beginning of a binary file
    — remove deprecation of aliased array parameters
    — conversion of array to pointer not limited to lvalues
    — relaxed constraints on aggregate and union initialization
    — relaxed restrictions on portable header names
    — return without expression not permitted in function that returns a value (and vice versa)
    Last edited by Dave_Sinkula; 02-23-2005 at 09:34 AM. Reason: Added material from C99 Foreward.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    http://www.open-std.org/jtc1/sc22/wg14/www/docs/n869/
    A free copy of the last draft version of C99
    It has a list of major differences.

    For C to C++ differences.
    http://david.tribble.com/text/cdiffs.htm


    > and what standard does C++ use?
    The current one is C++98, which only takes into account what is in C89.
    A revised C++ standard MAY take into account some of the new things added in C99
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    - Variables must be declared at the top of each function.
    Variables in C89 can actually be declared at the beginning of any code block. The following is valid C89:
    Code:
    int main(void)
    {
      int a = 5;
    
      {
        int b;
    
        b = 7;
      }
    
      // Can't see b here
    
      return 0;
    }
    If you understand what you're doing, you're not learning anything.

  5. #5
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    And i thought there were only a few changes

    Thanks alot Dave , Salem and itsme86
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  6. #6
    ---
    Join Date
    May 2004
    Posts
    1,379
    itsme86, I had no idea you could do that! Thanks a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C89 or C99
    By talin in forum C Programming
    Replies: 6
    Last Post: 05-26-2008, 12:45 PM
  2. C99 C89
    By salvadoravi in forum C Programming
    Replies: 4
    Last Post: 01-21-2008, 07:43 AM
  3. My C89 RANT!
    By evildave in forum C Programming
    Replies: 12
    Last Post: 12-07-2005, 10:15 PM
  4. C99 and int main()
    By cwr in forum C Programming
    Replies: 8
    Last Post: 09-19-2005, 06:54 AM
  5. (struct s) {.one = 1}; Is this C99?
    By dwks in forum C Programming
    Replies: 2
    Last Post: 08-19-2005, 06:37 PM