Re: memcpy in D

2013-06-30 Thread Marco Leise
... or alternatively: // Simple integers can be compile-time literals (i.e. C's #define) enum ADDRESS_BUS_SIZE = 20; // 2^20 address bus // In D it is more ideomatic to put the array length first. // For example this wouldn't work: byte x, *y, memory[1 << ADDRESS_BUS_SIZE]; byte[1 << ADDRESS_BUS_S

Re: memcpy in D

2013-06-30 Thread Marco Leise
Am Sun, 30 Jun 2013 07:07:23 -0400 schrieb "Tyro[17]" : > What is the equivalent of memcpy > > module memcopy; > > immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus > byte memory[1 << ADDRESS_BUS_SIZE]; > > void main() > { > ushort val = 12345; > > for (int i = 0x12340; i < 0x12

Re: Windows parameter

2013-06-30 Thread David
Am 30.06.2013 22:20, schrieb shuji: > On Sunday, 30 June 2013 at 20:04:12 UTC, Anthony Goins wrote: >> On Sunday, 30 June 2013 at 19:03:13 UTC, shuji wrote: >>> this code is in a .cpp file >>> //funcs.lib >>> //windows includes... >>> HWND hwnd; >>> int setHWND(HWND extHwnd){ >>> hwnd = extHwnd

Re: Windows parameter

2013-06-30 Thread shuji
On Sunday, 30 June 2013 at 20:04:12 UTC, Anthony Goins wrote: On Sunday, 30 June 2013 at 19:03:13 UTC, shuji wrote: this code is in a .cpp file //funcs.lib //windows includes... HWND hwnd; int setHWND(HWND extHwnd){ hwnd = extHwnd; return 0; } So im trying to import from D like

Re: Windows parameter

2013-06-30 Thread Anthony Goins
On Sunday, 30 June 2013 at 19:03:13 UTC, shuji wrote: this code is in a .cpp file //funcs.lib //windows includes... HWND hwnd; int setHWND(HWND extHwnd){ hwnd = extHwnd; return 0; } So im trying to import from D like this. I dont think I can implement this line in C++ extern (C

Re: Windows parameter

2013-06-30 Thread shuji
this code is in a .cpp file //funcs.lib //windows includes... HWND hwnd; int setHWND(HWND extHwnd){ hwnd = extHwnd; return 0; } So im trying to import from D like this. I dont think I can implement this line in C++ extern (C++) {}

Re: Windows parameter

2013-06-30 Thread Simen Kjaeraas
On Sun, 30 Jun 2013 20:24:17 +0200, shuji wrote: int setHWND(HWND extHwnd){ hwnd = extHwnd; return 0; } And: extern (C++) { int setHWND(HWND hwnd); } See how these are different? One of them is an extern (C++) function, the other is a D function. In other word

Windows parameter

2013-06-30 Thread shuji
Can someone help me with this: I have a library which I try to import from D //funcs.lib //windows includes... HWND hwnd; int setHWND(HWND extHwnd){ hwnd = extHwnd; return 0; } //main.d pragma(lib, "gdi32.lib"); import core.runtime; import core.sys.windows.windows; extern (C++) {

Re: static opDispatch

2013-06-30 Thread bearophile
Artur Skawina: Error reporting for optional templated methods that exist, but fail to instantiate, can be very misleading; calling such methods explicitly sometimes helps to identify the problem. http://d.puremagic.com/issues/show_bug.cgi?id=10511 Bye, bearophile

Re: memcpy in D

2013-06-30 Thread Steven Schveighoffer
On Sun, 30 Jun 2013 07:40:31 -0400, monarch_dodra wrote: On Sunday, 30 June 2013 at 11:07:24 UTC, Tyro[17] wrote: What is the equivalent of memcpy module memcopy; immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus byte memory[1 << ADDRESS_BUS_SIZE]; void main() { ushort val = 12

Re: static opDispatch

2013-06-30 Thread David
> Try removing the 'const' - static methods have no 'this'. > > Error reporting for optional templated methods that exist, but fail > to instantiate, can be very misleading; calling such methods explicitly > sometimes helps to identify the problem. > > artur > Oh wow, so easy ... Thanks I tott

Re: static opDispatch

2013-06-30 Thread Artur Skawina
On 06/30/13 12:36, David wrote: > struct Bla { > static @property > Bla opDispatch(string s)() const { > pragma(msg, s); > return Bla(); > } > } > > void main() { > Bla.abc; > } > > --- > > abc > /d675/f256.d(10): Error: no property

Re: memcpy in D

2013-06-30 Thread monarch_dodra
On Sunday, 30 June 2013 at 11:47:49 UTC, David wrote: Doing it this way has the advantage of being CTFE-able, and (potentially) faster, as everything I ever read about D's memcpy is that it is slow. On Windows? Doesn't memcpy use libc memcpy on Linux? I honestly have no idea, I'm just repea

Re: memcpy in D

2013-06-30 Thread Dmitry Olshansky
30-Jun-2013 15:47, David пишет: Doing it this way has the advantage of being CTFE-able, and (potentially) faster, as everything I ever read about D's memcpy is that it is slow. On Windows? Doesn't memcpy use libc memcpy on Linux? Yup on Linux is pretty darn fast just as is with C/C++. It's th

Re: memcpy in D

2013-06-30 Thread David
> Doing it this way has the advantage of being CTFE-able, and > (potentially) faster, as everything I ever read about D's memcpy is that > it is slow. On Windows? Doesn't memcpy use libc memcpy on Linux?

Re: memcpy in D

2013-06-30 Thread monarch_dodra
On Sunday, 30 June 2013 at 11:07:24 UTC, Tyro[17] wrote: What is the equivalent of memcpy module memcopy; immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus byte memory[1 << ADDRESS_BUS_SIZE]; void main() { ushort val = 12345; for (int i = 0x12340; i < 0x1234A; i+= 2) {

memcpy in D

2013-06-30 Thread Tyro[17]
What is the equivalent of memcpy module memcopy; immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus byte memory[1 << ADDRESS_BUS_SIZE]; void main() { ushort val = 12345; for (int i = 0x12340; i < 0x1234A; i+= 2) { memcpy (&memory[i], &val, sizeof val); // D wa

Re: Opaque structs

2013-06-30 Thread monarch_dodra
On Sunday, 30 June 2013 at 08:18:39 UTC, Johannes Pfau wrote: Am Sat, 29 Jun 2013 17:38:38 +0200 schrieb "monarch_dodra" : On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote: > Shouldn't doing anything value-related on > an empty struct be invalid anyway? Why ? The fact that the s

static opDispatch

2013-06-30 Thread David
struct Bla { static @property Bla opDispatch(string s)() const { pragma(msg, s); return Bla(); } } void main() { Bla.abc; } --- abc /d675/f256.d(10): Error: no property 'abc' for type 'Bla' /d675/f256.d(10): Error: Bla i

Re: Passing a instance of a class to a thread via spawn?

2013-06-30 Thread Gary Willoughby
You must pass a shared object: Thanks!

Re: Opaque structs

2013-06-30 Thread Johannes Pfau
Am Sat, 29 Jun 2013 17:38:38 +0200 schrieb "monarch_dodra" : > On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote: > > Shouldn't doing anything value-related on > > an empty struct be invalid anyway? > > Why ? > > The fact that the struct has no members is an implementation > detail