Thread: include files not working?

  1. #1
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    include files not working?

    i am having issues with adding functions to a program that has a couple of my own header files and uses a couple of source files,

    it works ok and compiles, but now when i am adding new functions i keep getting hassle from the compiler, its basically telling me functions are not declared in scope or elements that i am passing to function are not declared,

    in the example below i cant understand why the following is not working >>

    here is one of the header files, declared in main() as #include "graphic.h"

    Code:
    #ifndef GRAPHIC_H_INCLUDED
    #define GRAPHIC_H_INCLUDED
    
    SDL_Surface *screen;
    SDL_Surface *temp;
    SDL_Surface *PegArea;
    SDL_Surface *Buttonarea;
    SDL_Surface *Gameboard;
    
    void DrawGameEvent(GamePieces solpeg[MAXDWN][MAXACR], bool peg_chosen);  //this is existing stuff that works fine 
    // > function is implemented in project source file GraphicSource.cpp
    
    void RefreshBoard(GamePieces solpeg[MAXDWN][MAXACR], MenuButton* pMenu); //this is existing stuff that works fine
    // > function is implemented in project source file GraphicSource.cpp
    
    void DrawBoard(); //this is my example that is not working  created just for this test, function is called in main() 
    //and implemented in project source file GraphicSource.cpp 
    
    
    #endif // GRAPHICS_H_INCLUDED
    
    #endif // GRAPHIC_H_INCLUDED
    the call in main() is like this >

    Code:
          InitBoard(solpeg);
          Drawboard();                           //the offending function
          Menu.InitButtons();

    the function itself in the source file i just wrote as

    Code:
    void DrawBoard()
    {
    
    }
    is there anything wrong with this? do i need to put some kind of arguments into the linker or something or am i missing something simple?
    Last edited by rogster001; 10-29-2009 at 03:33 AM.

  2. #2
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    functions are not declared in scope or elements that i am passing to function are not declared,
    Which one ? could you be more specific ? also based on the code you provided I would assume that its because your DrawBoard function has an uppercase B whereas in main your calling it with a lowercase b.
    Spidey out!

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    i just mean the Drawboard() one i showed as a test...i am going to check that spelling, i think it might have just been wrong case in this post as i typed it out

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    it was a typo in my source... i think i am seeing problems where there are none, cheers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using files to store aint working. HELPPpp!!!!
    By success972 in forum C Programming
    Replies: 3
    Last Post: 04-13-2009, 12:32 AM
  2. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 08:36 AM
  3. #include header files or .cpp files?
    By DoctorX in forum C++ Programming
    Replies: 3
    Last Post: 12-23-2006, 12:21 PM
  4. C: include files problem
    By threahdead in forum Linux Programming
    Replies: 4
    Last Post: 05-07-2004, 08:02 AM
  5. How do I include .cpp files in my main?
    By MadForIt in forum C++ Programming
    Replies: 8
    Last Post: 02-11-2002, 07:40 PM