Page 1 of 1

Unreal compiler errors when i'm compiling my OS

Posted: Sun Aug 30, 2015 12:11 am
by osdever
My problem is when I starting make to build and run my OS, it shows me unreal compiler errors such as that:

Code: Select all

scrio.h:1:6: error: expected 'while' before 'kprint'
 void kprint(const char * msg)
      ^
scrio.h:1:6: error: expected '(' before 'kprint'
scrio.h:1:13: error: expected primary-expression before 'const'
 void kprint(const char * msg)
             ^
scrio.h:1:29: error: 'kprint' was not declared in this scope
 void kprint(const char * msg)
                             ^
scrio.h:2:1: error: expected ')' before '{' token
 {
 ^
scrio.h:2:1: error: expected ';' before '{' token
scrio.h:3:23: error: 'msg' was not declared in this scope
  size_t size = strlen(msg);
                       ^
In file included from user.h:4:0,
                 from os365.h:4,
                 from kernel.cpp:10:
zbase.h:15:23: error: expected primary-expression before 'width'
 window::window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text)
                       ^
zbase.h:15:37: error: expected primary-expression before 'height'
 window::window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text)
                                     ^
zbase.h:15:52: error: expected primary-expression before 'x'
 window::window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text)
                                                    ^
zbase.h:15:62: error: expected primary-expression before 'y'
 window::window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text)
                                                              ^
zbase.h:15:65: error: expected primary-expression before 'const'
 window::window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text)
                                                                 ^
zbase.h:15:87: error: expected primary-expression before 'const'
 window::window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text)
                                                                                       ^
zbase.h:15:104: warning: cannot call constructor 'gets(word, word)::window::window' directly [-fpermissive]
 window::window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text)
                                                                                                        ^
zbase.h:15:104: note: for a function-style cast, remove the redundant '::window'
zbase.h:31:6: warning: type 'gets(word, word)::window' with no linkage used to declare function 'void printw(const char*, gets(word, word)::window)' with linkage [-fpermissive]
 void printw(const char * msg, window wnd);
      ^
zbase.h:32:6: warning: type 'gets(word, word)::window' with no linkage used to declare function 'bool drawObj(gets(word, word)::window)' with linkage [-fpermissive]
 bool drawObj(window target);
      ^
zbase.h:35:1: error: a function-definition is not allowed here before '{' token
 {
 ^
zbase.h:42:1: error: a function-definition is not allowed here before '{' token
 {
 ^
zbase.h:45:16: error: a function-definition is not allowed here before '{' token
 void drawmain(){
                ^
zbase.h:49:42: error: a function-definition is not allowed here before '{' token
 void printw(const char * msg, window wnd){
                                          ^
kernel.cpp:29:1: error: expected '}' at end of input
 }


I'm searched the errors, and found nothing. Code of error files:

Code: Select all

//zbase.h
//includes etc...
class window {
	public:
	size_t width;
	size_t height;
	size_t x;
	size_t y;
	const char * caption;
	const char * text;
	window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text);
};
window::window(size_t width, size_t height, size_t x, size_t y, const char * caption, const char * text)
{
	this->width=width;
	this->height=height;
	this->x=x;
	this->y=y;
	this->caption=caption;
	this->text=text;
}
class Widget {
	public:
	size_t width;
	size_t height;
	size_t x;
	size_t y;
};
void printw(const char * msg, window wnd);
bool drawObj(window target);
void z_init();
bool drawObj(window target)
{
	fillRect(target.width,target.height,target.x,target.y,LIGHT_GREY);
	fillRect(target.width,16,target.x,target.y,LIGHT_BLUE);
	vgaWriteStr(target.x+5,target.y+5,target.caption,LIGHT_GREEN,LIGHT_BLUE);
	vgaWriteStr(target.x+5,target.y+21,target.text,MAGENTA,LIGHT_GREY);
}
void delWin(window wnd)
{
	fillRect(wnd.width,wnd.height,wnd.x,wnd.y,BLACK);
}
void drawmain(){
	vgaWriteStr(0,0,"OS365 Kernel 1.0.2, Z Window System 1.1.0.                                              ",WHITE,LIGHT_BLUE);
	vgaWriteStr(0,471,"Press left CTRL to display main menu.                                                 ",WHITE,LIGHT_BLUE);
}
void printw(const char * msg, window wnd){
	int line_n = 0;
	for(int i; i != strlen(msg); i++)
	{
		if(msg[i] != '\n')
		{
			vgaPutchar(wnd.x+5+i,wnd.y+21+line_n,msg[i],LIGHT_GREEN,LIGHT_GREY);
		}
		else
		{
			line_n++;
		}
	}
}
//kernel.cpp
//includes etc...
void kernel_main()
{
	asm("cli");
	setupFonts();
	kprint("OS365 Kernel 1.0 is loaded.\nInitializing PIC...",0,0);
	init_pics(0x20,0x28);
	kprint("\nAll pre-start processes are finished. Preparing to load shell...\n",0,8);
	setGraphicsMode();
	shellStart();
}
//scrio.h
//includes etc...
void kprint(const char * msg)
{
	size_t size = strlen(msg);
	for(size_t i = 0; i < size; i++)
	{
		terminal_putchar(msg[i]);
	}
}

And also it got gets from something, but it was in other file.

Re: Unreal compiler errors when i'm compiling my OS

Posted: Sun Aug 30, 2015 1:24 am
by alexfru
I'm not sure why the compiler would want "while", except if you had "do {something;}" without a trailing "while (expr);".

Re: Unreal compiler errors when i'm compiling my OS

Posted: Sun Aug 30, 2015 10:17 pm
by Rusky
You may want to check the last #include in the file that defines kprintf. It's probably the source of the error.

Re: Unreal compiler errors when i'm compiling my OS

Posted: Mon Aug 31, 2015 12:47 am
by osdever
Rusky wrote:You may want to check the last #include in the file that defines kprintf. It's probably the source of the error.
It's vgaterm.h, and it's normal. What with zbase?