"Expected type-specifier" error

I am trying to make a wrapper class for TTF_Font from SDL_ttf.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef SDL_FONT_H
#define SDL_FONT_H

#include <iostream>
#include <string>
#include <SDL.h>
#include <SDL_ttf.h>

namespace sdl
{
	class Font
	{
		public:
			Font(std::string& file, int size) {
                            font = TTF_OpenFont(file.c_str(), size);
			    if(!font) std::cout << "sdl::Font error with file " << file << std::endl;
                        }
			~Font()	{if(font) TTF_CloseFont(font);}

                        operator TTF_Font*() {return font;}

		private:
			TTF_Font* font;
	};

	inline SDL_Surface* RenderTextSolid(TTF_Font* font, std::string& text, SDL_Color color)
               {return TTF_RenderText_Solid(font, text.c_str(), color);}

};

#endif // SDL_FONT_H 


MinGW is giving me
20: error: expected type-specifier before 'TTF_Font'
23: error: 'TTF_Font' does not name a type

Before making this header I had no problem with using TTF_Font. As you can see the header is included, its directory is listed in Code::Blocks global search directories and I checked the include guards and they don't conflict with SDL_ttf.h
I'm at a loss, especially because it workd before... any idea on possible causes?
Last edited on
Your code compiles without errors for me.
Well, this is embarrassing but turns out it was probably due to me having SDL both in the project and the compiler directories plus having moved the main headers outside of the standard SDL folder. When I made the wrappers I moved back the project's SDL headers inside their original folder, but not the compiler's and I suppose that caused the issue
Topic archived. No new replies allowed.