[Gambas-devel] Problems inheriting Stream

tobi tobias at ...692...
Sun Apr 22 13:28:48 CEST 2012


Hi,

I have problems correctly inheriting Stream. I thought, I followed the instructions, Benoît gave me:

---
struct nc_window
{
	GB_BASE ob;
	GB_STREAM stream;
	...
};
---

with

---
GB_DESC CWindowDesc[] =
{
	GB_DECLARE("Window", sizeof(struct nc_window)),
	GB_INHERITS("Stream"),
	GB_AUTO_CREATABLE(),
	...
};
---

I have a set of functions and the

---
GB_STREAM_DESC WindowStream =
{
open: Window_stream_open,
close: Window_stream_close,
read: Window_stream_read,
getchar: Window_stream_getchar,
write: Window_stream_write,
seek: Window_stream_seek,
tell: Window_stream_tell,
flush: Window_stream_flush,
eof: Window_stream_eof,
lof: Window_stream_lof,
handle: Window_stream_handle
};
---

In the class constructor, I do:

---
...
THIS->stream.desc = &WindowStream;
THIS->tag = THIS;
...
---

When, in a test program, I do:

---
Dim cBuf As Byte

cBuf = Read #Window As Byte
---

a segfault occurs:

---
Program received signal SIGSEGV, Segmentation fault.
0x0805cc64 in SUBR_read (code=32000) at gbx_subr_file.c:399
399 stream = get_stream(PARAM, TRUE);
---

As I don't understand that macro, I've to ask: Any ideas?

Regards,
Tobi





More information about the Devel mailing list