www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - modules && type inheritance?

reply MM <MM_member pathlink.com> writes:
I use derelics for my sdl/opengl application and I wanted to make one module to
hold all my structures. I don't know much about scope and inheritance of types
and thus don't know how to make this work :(
In my structures I use the OpenGL types (GLubyte etc.)
What do I have to do to make these types visible to other modules?
Or.. where can I read about this :)
btw. Is it really necessary to use the gl types iso d types?
Jun 25 2006
parent reply BCS <BCS pathlink.com> writes:
MM wrote:
 I use derelics for my sdl/opengl application and I wanted to make one module to
 hold all my structures. I don't know much about scope and inheritance of types
 and thus don't know how to make this work :(
 In my structures I use the OpenGL types (GLubyte etc.)
 What do I have to do to make these types visible to other modules?
 Or.. where can I read about this :)
 btw. Is it really necessary to use the gl types iso d types?
 
 

<code name="structs.d"> struct foo{int i;} </code> <code name="other.d"> import structs; void main() { foo bar; bar.i = 3; return; } </code>
Jun 26 2006
parent reply MM <MM_member pathlink.com> writes:
import the structures module in any module that will need to use them


<code name="structs.d">
struct foo{int i;}
</code>

<code name="other.d">
import structs;

void main()
{
  foo bar;
  bar.i = 3;
  return;
}
</code>

Thx for the reply, and sorry for my ambigious question :) I import like this: import std.string; import std.c.stdio; import derelict.util.exception; import derelict.opengl.gl; import derelict.sdl.sdl; import derelict.sdl.image; import derelict.opengl.glu; import structures; And get this error: structures.d(19): identifier 'GLubyte' is not defined
Jun 26 2006
parent reply BCS <BCS pathlink.com> writes:
MM wrote:
import the structures module in any module that will need to use them


<code name="structs.d">
struct foo{int i;}
</code>

<code name="other.d">
import structs;

void main()
{
 foo bar;
 bar.i = 3;
 return;
}
</code>

Thx for the reply, and sorry for my ambigious question :) I import like this: import std.string; import std.c.stdio; import derelict.util.exception; import derelict.opengl.gl; import derelict.sdl.sdl; import derelict.sdl.image; import derelict.opengl.glu; import structures; And get this error: structures.d(19): identifier 'GLubyte' is not defined

derelict import defines GLubyte and add an import line for it in structures.d.
Jun 26 2006
parent reply MM <MM_member pathlink.com> writes:
"structures.d" will need to import anything that it needs, so find which 
derelict import defines GLubyte and add an import line for it in 
structures.d.

Adding import derelict.opengl.gl; did the trick :) Note to self > Modules are no C Header files :D thx. Would you by chance know whether it is necessary/good programming to use the opengl types iso D types? :)
Jun 26 2006
parent James Pelcis <jpelcis gmail.com> writes:
MM wrote:
 Would you by chance know whether it is necessary/good programming to use the
 opengl types iso D types? :)

difference.
Jun 26 2006