For starters, your first delegate is declared in an extern(C) block,
meaning it has C linkage. The second is declared outside of the block,
meaning it has D linkage. So they are two different types of delegates.
What is the difference?
Secondly, I'm not sure if you can pass delegates to a C
Am 05.06.2010 13:33, schrieb Zarathustra:
Secondly, I'm not sure if you can pass delegates to a C function. C code
wouldn't understand delegates. They are not the same as function
pointers. I suggest you use function pointers instead, paying attention
to linkage.
Of course It is possible,
only with static methods - a real delegate needs the this-pointer in a
register (not on the stack), thats the main difference between function
ptr and delegates, thats why you can't use a (non static) method on for
example the win-api callbacks, because the caller don't know your object
gcc:
Am 05.06.2010 15:42, schrieb Zarathustra:
only with static methods - a real delegate needs the this-pointer in a
register (not on the stack), thats the main difference between function
ptr and delegates, thats why you can't use a (non static) method on for
example the win-api callbacks,
Am 05.06.2010 16:03, schrieb dennis luehring:
Am 05.06.2010 15:42, schrieb Zarathustra:
only with static methods - a real delegate needs the this-pointer in a
register (not on the stack), thats the main difference between function
ptr and delegates, thats why you can't use a (non static)
Jesse Phillips jessekphillip...@gmail.com wrote in message
news:htue1b$2so...@digitalmars.com...
D1.x has an alias for string to char[]
Phobos does, but Tango doesn't seem to.
but that will help on the caller side (you using gcc?) but D still won't
accept an delegat in an extern C because this type does not exists in
the C world
Maybe it is the reason but the error message is still nonsense.
btw: can show us code where you do this and it works - why don't you use
Do you know why this D2 program prints const(char)[] instead of char[] ?
import std.stdio: writeln;
void main() {
int[char[]] data = [cast(char[])foo : 1];
foreach (key, val; data)
writeln(typeid(typeof(key)));
}
Bye and thank you,
bearophile
On Sat, 05 Jun 2010 20:42:43 -0400, bearophile bearophileh...@lycos.com
wrote:
Do you know why this D2 program prints const(char)[] instead of
char[] ?
import std.stdio: writeln;
void main() {
int[char[]] data = [cast(char[])foo : 1];
foreach (key, val; data)