April 19, 2024, 02:53:49 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Problems With Source Files

Started by Zen, December 11, 2005, 03:36:45 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

Zen

Hi. Im still getting those problems using Classes in one file and my main subroutine in another. Ive tried copying the class definition into my main file, putting it in a seperate file and including it in both the class and main program files and im still getting compile errors.

Lewis

Parker

That's odd. I have 4 or 5 classes in one header file that every file includes and it works fine. Maybe you could post the errors you're getting and the class definitions and I can help.

Zen

Ok main source file:


class myWindow : window {

declare OnCreate();
declare OnClose();

}

global sub main() {

myWindow Win;

Win.Create(0,0,640,480,AWS_CAPTION|AWS_VISIBLE|AWS_BORDER|AWS_SYSMENU|AWS_AUTODRAW,0,"Test GUI",null);

do {

wait();

} until Win.m_hwnd = 0;

return;

}


And The Class File


class myWindow : window {

declare OnCreate();
declare OnClose();

}

myWindow :: OnClose() {

Destroy();

return true;

}

myWindow :: OnCreate() {

CenterWindow();

return true;

}


And the errors...


Compiling...
Main
C:\Documents and Settings\Administrator\My Documents\Projects\GUI\Main.src:23: error: symbol `myWindow@OnClose' undefined
C:\Documents and Settings\Administrator\My Documents\Projects\GUI\Main.src:23: error: symbol `myWindow@OnCreate' undefined
Error(s) in assembling "C:\Documents and Settings\Administrator\My Documents\Projects\GUI\Main.asm"
myWindow


Any ideas?
Lewis

Ionic Wind Support Team

Give me a minute to look into it.

Paul.
Ionic Wind Support Team

Ionic Wind Support Team

It's a small logic bug...will fix shortly.

Instead of duplicating your class definition you shour really use an include file.  Not that that would make a difference in this case.

Paul.
Ionic Wind Support Team

Parker

Oh, I see. My classes aren't using virtual functions. Not much I can do since it's a compiler bug :)

Ionic Wind Support Team

Yes they are.  Just use the virtual keyword until I fix the bug.


class myWindow : window {

declare virtual OnCreate();
declare virtual OnClose();

}


The compiler was correctly marking the function as virtual, since the base class function was declared as such.  But it was neglecting to check to see if it was an external function.

C++ forces the virtual keyword on derived classes, I am attempting to avoid it ;)

Paul.
Ionic Wind Support Team

Parker

The window ones are, but I was referring to classes that I use for stacks, dictionaries, etc.

Ionic Wind Support Team

Ionic Wind Support Team