Thread: writing backwards?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Overworked_PhD View Post
    Technically it's undefined behavior. I can prove this by citing the bad line of code and the corresponding ANSI/ISO C passage.
    As it's written, or making the change suggested by the comments?

  2. #2
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by tabstop View Post
    As it's written, or making the change suggested by the comments?
    The original code, as it was presented, is technically undefined behavior. Now let's all wait for lasertard, I might laserlight to recite the corresponding passage.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Overworked_PhD View Post
    The original code, as it was presented, is technically undefined behavior. Now let's all wait for lasertard, I might laserlight to recite the corresponding passage.
    Whether or not to wait for LL is up to you naturally, but I'll go out on a limb and say I don't believe you. For reference, the code I'm looking at is
    Code:
    #include <stdio.h> /*why not just use stdlib.h? */
    
    int
    main ()
    {
      printf ("Hello \n World!\n");
      return 1;
    }

  4. #4
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by tabstop View Post
    Whether or not to wait for LL is up to you naturally, but I'll go out on a limb and say I don't believe you. For reference, the code I'm looking at is
    Code:
    #include <stdio.h> /*why not just use stdlib.h? */
    
    int
    main ()
    {
      printf ("Hello \n World!\n");
      return 1;
    }
    This line

    Code:
    int
    main ()
    should either be

    Code:
    int
    main (void)
    or

    Code:
    int
    main (int argc, char **argv)

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Overworked_PhD View Post
    This line

    Code:
    int
    main ()
    should either be

    Code:
    int
    main (void)
    or

    Code:
    int
    main (int argc, char **argv)
    The original is of course perfectly acceptable: 6.7.5.3, paragraph 14, says that
    An identifier list declares only the identifiers of the parameters of the function. An empty
    list in a function declarator that is part of a definition of that function specifies that the
    function has no parameters.
    And naturally 5.1.2.2.1 does not claim that the definition of int main must look exactly as given on the page, only that it be consistent with the definition.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems installing Mingw5.1.4
    By BlackOps in forum C Programming
    Replies: 2
    Last Post: 07-26-2009, 03:28 AM
  2. Replies: 2
    Last Post: 05-20-2008, 08:57 AM
  3. Very slow file writing of 'fwrite' function in C
    By scho in forum C Programming
    Replies: 6
    Last Post: 08-03-2006, 02:16 PM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. help! fifo read problem
    By judoman in forum C Programming
    Replies: 1
    Last Post: 08-16-2004, 09:19 AM