Thread: I have an error with my make file.

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    51

    I have an error with my make file.

    Hi there im currently working on a simple (simple for others not me lol) c++ object oriented game.
    I have several files which im trying to build with my SciTE compiler, however im running into an error when i try to build my program.
    Here is the error message which occurs in my main file called (tankmain.cpp) :

    ========================================
    >"C:\Program Files\gccscite\bin/run" make
    g++ -c -fpermissive -fconserve-space tankmain.cpp
    tankmain.cpp:23: error: expected unqualified-id before "using"
    make: *** [tankmain.o] Error 1
    >Exit code: 2
    ========================================

    Here are the first 25 lines of code from my tankmain.cpp

    Code:
    ////////////////////////////////////////////////////////////////////////////////////
    //        Author : Casey Smith
    //			 ID# : 07199104
    //			 Paper # : 159234
    //										Description: TANK GAME
    ////////////////////////////////////////////////////////////////////////////////////
    
    #include <iostream>
    #include <windows.h>
    #include <stdio.h>
    #include <math.h>
    #include <time.h>
    #include "world.h"
    #include "tankmain.h"
    
    
    using namespace std; //this is line 23 in the scite editor.. i left the top comments out.
    
    int main (void){
    Any help would be appreciated just to get me over this hump.

    Regards.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The problem isn't in tankmain.c but in (probably) tankmain.h where I expect you missed out a semicolon or have some extra "rubbish" in the file [I have been known to accidentally put characters at the beginning or end of files when not paying attention to what I'm doing, and end up with "strange" errors like this].

    --
    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
    Oct 2007
    Posts
    51
    Thanks for the suggestion.

    I tried removing tankmain.h, as it has nothing in it yet (I removed it from the make file, main file and deleted the file itself) And I still receive the same error.

    I then added everything back in and tried putting the .h files in this order.

    Code:
    #include "tankmain.h"
    #include "world.h"
    and I still receive the same error.

    Maybe this will help clarify the problem.. This is the content of my world.h and make file

    world.h // pardon the class's I am not entierly sure if they are correct it some of the stuff im learning at the moment
    Code:
    #ifndef __WORLD_H__
    #define __WORLD_H__
    
    
    #include <math.h>
     
    
    using namespace std;
    
    
    class boundaryType {
    	public:
    		float x1,y1,x2,y2;
    };
    
    class world2D {
    	public:
    	float degToRad (float);	
    	int Xdev(void);
    	int Ydev(void);
    }
    
    #endif
    Makefile
    Code:
    tankmain.exe		: 	tankmain.o graphics.o world.o
    	g++ -Wl,-s -o tankmain.exe tankmain.o graphics.o world.o 
    			
    tankmain.o		:	tankmain.cpp tankmain.h graphics.h
    	g++ -c -fpermissive -fconserve-space tankmain.cpp	
    	
    world.o 			: world.cpp world.h  
    	g++ -c -fpermissive -fconserve-space world.cpp
    
    graphics.o		:	 graphics.cpp graphics.h
    	g++ -c -fpermissive -fconserve-space graphics.cpp
    again thanks for the help !
    Last edited by webznz; 08-19-2008 at 05:52 AM. Reason: spelling

  4. #4
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    You're missing a semicolon at the end of your world2D class.

    Code:
    class world2D {
    	public:
    	float degToRad (float);	
    	int Xdev(void);
    	int Ydev(void);
    };
    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, of course, if you include an empty header file (or one that has been included previously and is properly guarded against multiple inclusion), then the previous header file becomes the candidate, and so on with this type of error.

    --
    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.

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    51
    Thanks guys.. the missing semicolon was the key!
    God you get so caught up thinking its one this you miss something small like that!!!
    thanks again.. now I got a bunch of errors to deal with! lol

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > God you get so caught up thinking its one this you miss something small like that!!!
    > thanks again.. now I got a bunch of errors to deal with! lol
    Well if you'd compiled it 5 minutes after writing it, rather than what - a few hours, then you'd have a lot less errors to look at, and a lot more idea of where to start looking.
    http://cboard.cprogramming.com/showthread.php?t=88495

    In short, don't code beyond your ability to deal with the compiler throwing the whole lot back at you as utter garbage.

    With a decent makefile (like you have), it shouldn't take more than a few seconds to check you're still on track.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  4. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM