Thread: Compiler treating a function as a variable

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    2

    Compiler treating a function as a variable

    I'm stumped.

    I'm using Dev-cpp as my IDE, compiler is hitting just one line with errors:

    Line 36 : variable or field `destroyDirt' declared void
    Line 36 : expected `;' before '(' token

    Line 36 is void destroyDirt(xyCord);

    the surrounding code is:
    Code:
    		// class constructor
    		DirtField(SDL_Surface * battlefield);
            
    		// class destructor
    		~DirtField();
    		
    		// destroy the dirt (if present) at the specified point
    		void destroyDirt(xyCord);
    This header file seems otherwise fine. Moving that function declaration within the file does not change the error (the line number of the error follows this function). If I comment out this function (and it's related definition) it compiles fine.

    I am terribly vexed...

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Where is xyCord defined, and how?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    2
    That would be in another header file that I totally spaced off including in this one.

    Now I just feel silly.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Virmitio View Post
    That would be in another header file that I totally spaced off including in this one.

    Now I just feel silly.
    Yes, I usually feel silly about that too - not quite as silly as when I thought (a > b) meant that it was true when "b is greater than a" just a few minutes ago tho'.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing a byte and its bits to a function
    By rtarbell in forum C Programming
    Replies: 9
    Last Post: 12-04-2008, 09:24 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  5. Static variable or function parameter?
    By Abda92 in forum C Programming
    Replies: 1
    Last Post: 12-02-2007, 12:37 PM

Tags for this Thread