Curious GCC error messages

This is a discussion on Curious GCC error messages within the Tech Board forums, part of the Community Boards category; I'm curious as to the error messages issued from the following function declarations: Code: int return_array() []; Code: int return_array() ...

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,472

    Curious GCC error messages

    I'm curious as to the error messages issued from the following function declarations:

    Code:
    int return_array() [];
    Code:
    int return_array() ();
    error: `return_array' declared as function returning an array
    error: `return_array' declared as function returning a function
    I wouldn't ever think the compiler would check for the return type of a function after parameter list.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    It probably has an internal function, determine_token_type(), which parses "int array[10]" as well as "int function() [10]".

    [edit] As well, Java allows returning arrays, so perhaps they wrote it with other languages in mind. [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick Compilation Question
    By chacham15 in forum C Programming
    Replies: 10
    Last Post: 10-12-2008, 08:15 PM
  2. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  3. Replies: 4
    Last Post: 09-02-2007, 08:47 PM
  4. Compiles on gcc 3.3 but not on gcc 4.0.3
    By cunnus88 in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2007, 12:24 PM
  5. gcc
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-22-2003, 03:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21