Thread: Weird function declaration...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    129

    Exclamation Weird function declaration...

    While taking a look at nethacks source I've come to across this weird style to declare function (not a prototype):

    Code:
    const char*
    artifact_name(name, otyp)
    const char *name;
    short *otyp;
    {
        ...
    What sort of devil is this and how to get it work on my own files?

  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    That's the "old" C-style, before ANSI C. The "present day" equivilant is:

    Code:
    const char *artifact_name( const char *name, short *otyp )
    {
    }
    Jason Deckard

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Which is a really odd way of writing the code, since that should be only found in really old code, and not new code.

    I say new code, because it also uses const, which was not part of C until the first ANSI standard (which also introduced function prototypes).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM