Jump to content

  • Log In with Google      Sign In   
  • Create Account


Starting out with SDL...weird compiler error


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 TSLexi   Members   -  Reputation: 102

Like
0Likes
Like

Posted 24 January 2014 - 09:09 PM

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

Sponsor:

#2 Servant of the Lord   Crossbones+   -  Reputation: 18501

Like
0Likes
Like

Posted 24 January 2014 - 10:10 PM

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, 24 January 2014 - 10:14 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS