Compilation error... eyes needed

I just can’t see what’s wrong with my code, so here it is maybe i get lucky.

The errors:

/boot/home/Desktop/roller/DeskbarView.cpp:81: parse error before character 0302
/boot/home/Desktop/roller/DeskbarView.cpp:85: syntax error before `.'

The file in question:

#include "App.h"
#include "DeskbarView.h"
#include "SettingsWindow.h"

#include <AboutWindow.h>
#include <AppFileInfo.h>
#include <Bitmap.h>
#include <Deskbar.h>
#include <Entry.h>
#include <File.h>
#include <MenuItem.h>
#include <Region.h>
#include <PopUpMenu.h>
#include <Roster.h>
#include <View.h>
#include <Window.h>

#include <stdio.h>
#include <strings.h>


const uint32 kPause = 'puse';
const uint32 kResume = 'rsme';
const uint32 kNext = 'next';
const uint32 kPrevious = 'prvs';
const uint32 kSettingsWin = 'sttg';
//const uint32 kQuit = 'quit';


BView *instantiate_deskbar_item()
{
	return new DeskbarView();
}

DeskbarView::DeskbarView(bool inDeskbar)
	:	BView(BRect(0, 0, 15, 15), kRollerDeskbarName,
		B_FOLLOW_ALL, B_WILL_DRAW),
		fInDeskbar(inDeskbar)
{
	Init();
}

DeskbarView::DeskbarView(BMessage *message)
	:	BView(message),
	fInDeskbar(false)
{
		app_info info;
	if (be_app->GetAppInfo(&info) == B_OK
		&& !strcasecmp(info.signature, kDeskbarSignature))
		fInDeskbar = true;

	Init();
}

DeskbarView::~DeskbarView()
{

	delete fIcon;
}

void DeskbarView::Init()
{
	entry_ref ref;
	be_roster->FindApp(kRollerSignature, &ref);
	
	BFile			file(&ref, B_READ_ONLY);
	BAppFileInfo	appFileInfo(&file);
	fIcon = new BBitmap(BRect(0,0,15,15), B_CMAP8);
	appFileInfo.GetIcon(fIcon, B_MINI_ICON);
}

void DeskbarView::Quit()    */ Line 81 */
{
	if (fInDeskbar) {
		BDeskbar deskbar;
		deskbar.RemoveItem(kRollerDeskbarName);  */ Line 85*/ 
	} else
		be_app->PostMessage(B_QUIT_REQUESTED);
}

DeskbarView *DeskbarView::Instantiate(BMessage *message)
{
	if (validate_instantiation(message, kRollerDeskbarName))
	return new DeskbarView(message);

	return NULL;
	
}

	
status_t DeskbarView::Archive(BMessage *message, bool deep) const
{
	BView::Archive(message, deep);
	message->AddString("add_on",kRollerSignature);
	message->AddString("class",kRollerDeskbarName);

	return B_OK;
}


void DeskbarView::AttachedToWindow()
{
	BView::AttachedToWindow();

	SetViewColor(Parent()->ViewColor());

}


void DeskbarView::Draw(BRect rect)
{
	SetDrawingMode( B_OP_ALPHA );
	DrawBitmap(fIcon, BPoint(0.0, 0.0));
}


void DeskbarView::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case B_ABOUT_REQUESTED: {
			BAboutWindow *window = new BAboutWindow(
			"roller", kRollerSignature);

			const char *header = {
			"**ROLLER**"
			};
			
			const char *contents[] = {
			"\tA native wallpaper\n" 
			"\tchanger app for Haiku.",
				NULL
			};

			const char* authors[] = {
			"\tKhaled Berraoui.\n",
				NULL
			};

			window->AddText(header, contents);
			window->AddCopyright(2017, "Khaled Berraoui");
			window->AddAuthors(authors);

			window->Show();
			break;
		}
		case B_QUIT_REQUESTED: {
				Quit();
			break;
		}
		case kSettingsWin: {
				be_roster->Launch(kRollerSignature);
			break;
		}
		default: {
			BView::MessageReceived(message);
			break;
		}
	}
}


void DeskbarView::MouseDown(BPoint where)
{
	BPoint location;
	uint32 buttons;

	GetMouse(&location, &buttons);
	

	if (buttons & B_PRIMARY_MOUSE_BUTTON) {
		LeftClick(where);
	} else
	if (buttons & B_SECONDARY_MOUSE_BUTTON) {
		RightClick(where);
		
	}
}




void DeskbarView::LeftClick(BPoint where)
{
		BPopUpMenu *popup = new BPopUpMenu("popup", false, false);
		popup->AddItem(new BMenuItem("Pause",
		new BMessage(kPause)));
		popup->AddItem(new BMenuItem("Resume",
		new BMessage(kResume)));

		popup->AddSeparatorItem();

		popup->AddItem(new BMenuItem("Previous",
		new BMessage(kPrevious)));
		popup->AddItem(new BMenuItem("Next",
		new BMessage(kNext)));
		popup->SetAsyncAutoDestruct(true);
		popup->SetTargetForItems(this);
		ConvertToScreen(&where);
		popup->Go(where, true, true, true);
}


void DeskbarView::RightClick(BPoint where)
{
		BPopUpMenu *popup = new BPopUpMenu("popup", false, false);
		popup->AddItem(new BMenuItem("Settings",
		new BMessage(kSettingsWin)));
		popup->AddItem(new BMenuItem("About",
		new BMessage(B_ABOUT_REQUESTED)));

		popup->AddSeparatorItem();

		popup->AddItem(new BMenuItem("Quit",
		new BMessage(B_QUIT_REQUESTED)));
		popup->SetAsyncAutoDestruct(true);
		popup->SetTargetForItems(this);
		ConvertToScreen(&where);
		popup->Go(where, true, true, true);
}

Try using GCC7; it has much better error messages.

Have you cut&paste from the BeBook? I didn’t see this error since the BeOS time.

It’s a typical GCC error connected with copy and paste from certain sources (which by the way is not going to get any better with GCC7). What happened is that while you copied data from a website or similar source a non ASCII white space or punctuation has been copied. It looks like an ASCII character but is none. Lexers react badly to this. I see this kind of error often when copy-paste seemingly simple stuff from OpenGL API website. To fix it delete the text or line in question and type it anew by hand. This will remove the bogus character (often hidden by editors too). This should fix the problem.

2 Likes

Use a proper editor which highlight these :slight_smile: (vim has the “listchars” option for this).
Usually it’s a non-breakable space instead of a normal space.

1 Like

Thanks to all, for trying to help, i may have copy pasted from the bebook indded, i fixed it by opening the file in another Qt editor (FeatherPad) which can show whitespaces, fixing those made the error go away.