Hi, I'm new in D programming, and does not have much C experience either. After
reading TDPL book and playing with some sample codes, I came to decide to try
something more `practical`. I began with a Redis client binding from Hiredis C
code.
Hiredis is a small lib, and seems very simple to bind
Am 05.01.2012 17:21, schrieb Puming Zhao:
Hi, I'm new in D programming, and does not have much C experience either. After
reading TDPL book and playing with some sample codes, I came to decide to try
something more `practical`. I began with a Redis client binding from Hiredis C
code.
Hiredis is
On 01/05/2012 07:14 PM, Joshua Reusch wrote:
Am 05.01.2012 17:21, schrieb Puming Zhao:
Hi, I'm new in D programming, and does not have much C experience
either. After
reading TDPL book and playing with some sample codes, I came to decide
to try
something more `practical`. I began with a Redis cl
Puming Zhao wrote:
> Hi, I'm new in D programming, and does not have much C experience either.
> After reading TDPL book and playing with some sample codes, I came to
> decide to try something more `practical`. I began with a Redis client
> binding from Hiredis C code. Hiredis is a small lib, and
Am 05.01.2012 19:44, schrieb Timon Gehr:
On 01/05/2012 07:14 PM, Joshua Reusch wrote:
Am 05.01.2012 17:21, schrieb Puming Zhao:
Hi, I'm new in D programming, and does not have much C experience
either. After
reading TDPL book and playing with some sample codes, I came to decide
to try
something
Sure ? dlang.org says they are not:
http://www.d-programming-language.org/arrays.html#strings
Sorry, in the printf section: "String literals already have a 0 appended
to them, so can be used directly"
I missed this.
Your problem is that you're calling printf on a static char array. If
you're going to use printf you have to use it on the .ptr (pointer)
field of the static array. Replace this call:
printf("Connection error: %s\n", c.errstr);
with
printf("Connection error: %s\n", c.errstr.ptr);
On my en
Andrej Mitrovic:
> I think `long long` in C is 8 bytes, which is the
> equivalent to D's long type.
I think C just requires:
sizeof(long long int) >= sizeof(long int).
For the actual size I think you have to ask to the C compiler.
Bye,
bearophile
On Thursday, 5 January 2012 at 22:02:25 UTC, Andrej Mitrovic
wrote:
Your problem is that you're calling printf on a static char
array. If
you're going to use printf you have to use it on the .ptr
(pointer)
field of the static array. Replace this call:
printf("Connection error: %s\n", c.err
So you have "int integer;" in D and "long long integer;" in C,
which doesn't match. I'm not sure what size "long long" is in
C, but I guess you need "long" in D?
Thanks. I've changed `int integer` to `c_long integer` according
to this page
http://dlang.org/interfaceToC.html
c_long is in cor
On 1/6/2012 11:38 AM, Puming wrote:
On Thursday, 5 January 2012 at 22:02:25 UTC, Andrej Mitrovic wrote:
Your problem is that you're calling printf on a static char array. If
you're going to use printf you have to use it on the .ptr (pointer)
field of the static array. Replace this call:
printf
I think the problem still lies with your declaration of the
integer field. c_long in D is supposed to be equivalent to the
long type in C, *not* long long. It is declared as 32 bits on a
32-bit system and 64 bits on a 64-bit system. I believe that in
practice, most C compilers implement long
Here is what I've got so far:
1. "long long" in C is always 64bit, so in D it's "long";
2. C's char* string should be converted to!string when used in
"writeln";
3. String literals in D -IS- zero terminated;
And now it's working fine. Thanks everybody :)
On 1/6/2012 2:34 PM, Puming wrote:
In http://dlang.org/interfaceToC.html it says in 32bit system c_long is
equivalent to `long long` in C. Is this wrong?
Well, either the documentation is wrong or the implementation is. Looks
like one for Bugzilla.
Mike Parker wrote:
> On 1/6/2012 2:34 PM, Puming wrote:
>>
>>>
>> In http://dlang.org/interfaceToC.html it says in 32bit system c_long is
>> equivalent to `long long` in C. Is this wrong?
>
> Well, either the documentation is wrong or the implementation is. Looks
> like one for Bugzilla.
The doc
Puming:
> 1. "long long" in C is always 64bit, so in D it's "long";
In C "long long" isn't always 64 bit.
Bye,
bearophile
On 1/6/12, Johannes Pfau wrote:
> The documentation is wrong.
That was my fault. I was going to fix the original docs which had no
mention of c_long/c_ulong and I ended up screwing up the tables.
Sorry!
17 matches
Mail list logo