• Advertisement
Sign in to follow this  

Starting out with SDL...weird compiler error

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm starting out SDL development, and I'm getting an odd compiler error. Compiler is C4Droid (G++ with C++11 extensions). Platform is Android 4.3.2.

Compiler error is:

In file included from /storage/emulated/0/Game/CApp.cpp:1:0:/storage/emulated/0/Game/CApp.hpp:6:1: error: stray '\302' in program     public: ^compilation terminated due to -Wfatal-errors.In file included from /storage/emulated/0/Game/Main.cpp:1:0:/storage/emulated/0/Game/CApp.hpp:6:1: error: stray '\302' in program     public: ^compilation terminated due to -Wfatal-errors.
CApp.hpp
#ifndef CAPP_HPP#define CAPP_HPP#include class CApp {    public:        CApp();        int OnExecute();        bool OnInit();        void OnEvent(SDL_Event* Event);        void OnLoop();        void OnRender();        void OnCleanup();      private:      bool running;      SDL_Surface* Display;};#endif
CApp.cpp
#include "CApp.hpp"CApp::CApp():Display(0),running(true){}int CApp::OnExecute() {    if (OnInit() == false)      return -1;      SDL_Event Event;      while (running)      while (SDL_PollEvent(&Event))      OnEvent (&Event);      OnLoop();      OnRender();      OnCleanup();      return 0;}bool CApp::OnInit(){	if (SDL_Init(SDL_INIT_EVERYTHING) < 0)	return false;	if((Display = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF)) == 0)         return false;else    return true;}void CApp::OnEvent(SDL_Event* Event){if (Event -> type == SDL_QUIT)running = false;}	void CApp::OnCleanup(){	SDL_Quit();}void CApp::OnRender(){}void CApp::OnLoop(){}
Main.cpp
#include "CApp.hpp"int main (){return CApp().OnExecute();}
Oddly enough, it compiled fine when all three files were merged.

Any advice?

Thanks,
Lexi

Share this post


Link to post
Share on other sites
Advertisement

You probably copied+pasted the code from a website, right?

 

The "stray '\302'" I think is an invisible Unicode character (used for formatting on whatever website) that you accidentally copied with the visible text. That happens occasionally. happy.png

 

Go to the very first cursor position of the document, and hit 'backspace' a few dozen times, to remove any leading invisible characters.

Then, go to the very last cursor position of the document, and hit 'delete' a few dozen times, to remove any following invisible characters.

You'll have to do that for all three documents.

 

Or you could paste them into Notepad, and save them as ASCII, Notepad would warn about the unicode characters, but you could save anyway, and the unicode characters would (if I recall correctly) convert into squares which you could more easily delete.

Edited by Servant of the Lord

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement