www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - how to correctly 'typedef' handle types

reply "midi" <midiway midi.rs> writes:
import std.stdio;
import core.sys.windows.windows;

int main(string[] argv)
{
	HGDIOBJ h;

	// Compile error:
	// Error	1	Error: main.foo called with argument types (void*) 
matches both:	D:\Projetos-D\ConsoleApp1\main.d	12
	// Error	2	main.foo(void* h)	D:\Projetos-D\ConsoleApp1\main.d	17
	// Error	3	main.foo(void* h)	D:\Projetos-D\ConsoleApp1\main.d	21
	foo(h);

     return 0;
}

void foo(HGDIOBJ h)
{
}

void foo(HACCEL h)
{
}



I want my 2 overloaded 'foo' functions to be able to 
differentiate when the passed parameter is a HGDIOBJ or a 
HACCEL...but it doesn't compile (error in the code above)

The problem lies in how I am declaring those 2 types cause they 
are aliases for the same base type: 'void*'

dont't know how to solve it! thks for helping
Jun 19 2014
parent reply "francesco cattoglio" <francesco.cattoglio gmail.com> writes:
http://dlang.org/phobos/std_typecons.html#Typedef

Take a look at it. Docs is scarce (pretty sure you will need to 
take a look around to find something) but it should just do what 
you need.
Jun 20 2014
parent "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
On Friday, 20 June 2014 at 07:05:49 UTC, francesco cattoglio 
wrote:
 http://dlang.org/phobos/std_typecons.html#Typedef

 Take a look at it. Docs is scarce (pretty sure you will need to 
 take a look around to find something) but it should just do 
 what you need.
The prerelease docs contain more information:
Jun 20 2014