Strange Issues regarding aliases

Joerg Joergonson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 14 08:29:23 PDT 2016


I have stuff like


public static class fGL
{
	nothrow @nogc extern(System)
	{
		alias CullFace = void function(tGL.Enum);
		alias FrontFace = void function(tGL.Enum);
		alias HInt = void function(tGL.Enum, tGL.Enum);
		alias LineWidth = void function(tGL.Float);
		alias PoIntSize = void function(tGL.Float);
                 ...
         }
}


public static struct tGL
{
	alias Void = void;
	alias IntPtr = ptrdiff_t;
	alias SizeInt = int;
	alias Char = char;
	alias CharARB = byte;
	alias uShort = ushort;
	alias Int64EXT = long;
	alias Short = short;
	alias uInt64 = ulong;
	alias HalfARB = ushort;
         alias BlendFunc = void function(tGL.Enum, tGL.Enum);
         ...

         __gshared {
	    CopyTexImage1D glCopyTexImage1D;
             TextureParameterf glTextureParameterf;
             VertexAttribI3ui glVertexAttribI3ui;
             VertexArrayElementBuffer glVertexArrayElementBuffer;
             BlendFunc glBlendFunc;
             ...
}


public struct eGL
{
	enum ubyte FALSE = 0;
	enum ubyte TRUE = 1;
	enum uint NO_ERROR = 0;
	enum uint NONE = 0;
	enum uint ZERO = 0;
	enum uint ONE = 1;
         ...
}


And when I use this stuff(which is clearly openGL being cleaned 
up a bit(I know I can use modules to essentially do this too but 
that is irrelevant):

I get errors like


Error: null has no effect in expression (null)	

Error: more than one argument for construction of extern 
(Windows) void function(uint, uint) nothrow @nogc	


This is when using it like

fGL.BlendFunc(eGL.SRC_ALPHA, eGL.ONE_MINUS_SRC_ALPHA);

What's going on? Please no responses about "You are going to run 
into a lot of problems since all the openGL code uses the flat 
accessing"... The whole point is to get away from that ancient 
way and backwards way.




More information about the Digitalmars-d-learn mailing list