Public Group

missing storage-class or type specifiers

This topic is 4907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I get these errors:
d:\Documents\CPP\Visual Studio Projects\TileSystem\Game.h(30) : error C2143: syntax error : missing ';' before '*'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Game.h(30) : error C2501: 'Game::Console' : missing storage-class or type specifiers
d:\Documents\CPP\Visual Studio Projects\TileSystem\Game.h(30) : error C2501: 'Game::Console' : missing storage-class or type specifiers


On this line: Console* Console; // for the console Im trying to do a console and for some reason it seems not to recognice my console class. Console.h is included and the class is defined there, if it wasnt it should state other errors to, shouldnt it? What could be wrong?

Share on other sites
Console * console;

Share on other sites
Console * Console; == Console* Console;

Right?

Share on other sites
"Console * console" != "Console * console" (case matters).

Share on other sites
I changed the line to this but I still gets the exact same errors... you sure thats whats wrong?

Console * console; // for the console

Share on other sites
Console * Console;

Is fine in C++, as is

Console *Console;

And

Console* Console;

The only problem with doing this is that it hides the Console class for the rest of the scope in which the Console variable is defined. For example

class Console{...};int main(){  Console * Console;  Console * Console2;}

Here the Console * Console2; line will give you an error, as it thinks Console is now a variable of type pointer, and interprets Console * Console2; as a multiplication, since Console2 has not been previously defined, you get an error.

There is a way around this, you can qualify the second Console definition with the class keyword, that will tell the compiler that Console refers to a class, and not a variable of type pointer.

class Console{...};int main(){Console * Console;class Console * Console2;}

This now compiles. This is an example of using an 'elaborated type specifier'. You will need to post more code describing the problem.

Share on other sites
Yup, thanks, that solved it. But on the line above I have

FontSystem* Font; // for printing text on the screen

Which works fine, why not the console? I couldnt find anywhere in the project where I did make another Console class as you showed there.

Share on other sites
Quote:
 Original post by MizipzorYup, thanks, that solved it. But on the line above I haveFontSystem* Font; // for printing text on the screenWhich works fine, why not the console? I couldnt find anywhere in the project where I did make another Console class as you showed there.

In this case it is likely that the elaborated type specifier simply declared the Console class as existing somewhere in the project. This suggests that you have not actually included the Console header file in the .cpp file that the line of code Console * Console exists in. It is worth you double checking.

Share on other sites
Console.h is included.

Game.h (as you can see, the console is at the top and I got other class pointers working fine)
#ifndef _GAME#define _GAME#include <SDL.h>#include <stdio.h>#include <stdlib.h>#include <conio.h>#include <windows.h>#include "SdlHandle.h"#include "Player.h"#include "AsciiMap.h"#include "Log.h"#include "Defines.h"#include "FontSystem.h"#include "Console.h"class Game {protected:	// Singleton class	static Game* m_pInstance;	Game( void );private:	SdlHandle*	Sdl;			// for the graphics	Player		Player;			// the player	AsciiMap	AsciiMap;		// the tiles represented by chars	Log			Log;			// for the logs	FontSystem*	Font;			// for printing text on the screen	class Console*	Console;		// for the Console		bool		running;		// is the game running	Uint8*		keys;			// to keep track of the keys	SDL_Event	event;			// event tracker (keys)public:	// Singleton ---	static Game* GetInstance( void ) {		if ( !m_pInstance )			m_pInstance = new Game();		return m_pInstance;	};	// init stuff ---	bool	InitVideo();		// init graphics	// main stuff --- 	void	RenderWorld();		// draws all the tiles	void	MainLoop();			// the main loop	void	RawCommand(std::string Command);	// for recieving raw commands from the Console};#endif

Share on other sites
Its possible you could have some circular dependancy issues. Does the Console.h file include the Game.h header file too?

1. 1
2. 2
Rutin
21
3. 3
A4L
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633736
• Total Posts
3013603
×