On Sunday, 1 December 2013 at 04:11:57 UTC, Simen Kjærås wrote:
On 2013-12-01 04:46, Craig Dillabaugh wrote:
Since questions about calling C from D seem to be popular
today, I
thought I would throw this one out there.
I am trying to call a C function which takes as parameters
several
arrays o
On 2013-12-01 04:46, Craig Dillabaugh wrote:
Since questions about calling C from D seem to be popular today, I
thought I would throw this one out there.
I am trying to call a C function which takes as parameters several
arrays of doubles. It is valid to have some arrays passed a NULL
pointers
On 12/1/2013 12:46 PM, Craig Dillabaugh wrote:
Is there an accepted 'proper' way of passing NULL pointers to C
functions from D?
shape_ptrs ~= SHPCreateSimpleObject( SHPT_POLYGON, to!int(x1.length),
x1.ptr, y1.ptr, null );
Since questions about calling C from D seem to be popular today,
I thought I would throw this one out there.
I am trying to call a C function which takes as parameters
several arrays of doubles. It is valid to have some arrays
passed a NULL pointers in the C code.
To call this from D I've com
On Saturday, 30 November 2013 at 14:53:35 UTC, Gary Willoughby
wrote:
I'm porting some C headers and wondered how would i convert the
following to D:
#define pthread_self() GetCurrentThreadId()
#define pthread_handler_t void * __cdecl
typedef void * (__cdecl *pthread_handler)(void *);
#defin
On Saturday, 30 November 2013 at 08:35:23 UTC, Frustrated wrote:
I need to pass around some objects(specifically int[]) that may
be used by several other objects at the same time. While I
could clone these and free them when the parent object is done
this wastes memory for no real reason except
I write a function with Lambda expression + safe + pure wich do
same (close) as countUntil
http://www.dpaste.dzfl.pl/63d03540
but i fail to use lambda expression into my function. I try by
two way
- alias this pred … (to get a default lambda)
- function(…) pred
both way i fail, could you tak
On Saturday, 30 November 2013 at 12:51:46 UTC, Rene Zwanenburg
wrote:
On Saturday, 30 November 2013 at 08:35:23 UTC, Frustrated wrote:
I need to pass around some objects(specifically int[]) that
may be used by several other objects at the same time. While I
could clone these and free them when
I just confirmed the same behavior on Ubuntu amd64. dmd 2.063.2
compiles the example and dmd 2.064.2 produces the same error as
the Windows 32 bit version.
The following is boiled down from a real world context. I'm using
dmd 2.064.2 Windows. Can someone please explain what's going on.
struct my_integer {
int val = 99;
alias val this;
//this( int n) { val = n; }
}
struct blah {
my_integer Integer;
this( int
class A
{
bool reset;
void delegate dtor();
~this()
{
if (!reset)
dtor();
}
}
class B
{
A a;
bool run;
~this() { if (!run) a.reset = true; run = true; }
}
A a = new A;
B b = new B;
b.a = a;
b.a.dtor = & b.__dtor;
relying on to "bool reset" it's no good id
Thanks all.
On Saturday, 30 November 2013 at 18:58:30 UTC, Ali Çehreli wrote:
However, I doubt that .dup copies that '\0' character. Although
the literal has the termination, we are in slice land beyond
that literal so the termination must somehow be ensured.
Ali
Hm, yes, this also sounds like a valid c
On 11/30/2013 07:59 AM, Adam D. Ruppe wrote:
tempBuffer[name.length] = 0; // make sure it is zero terminated
yourself
Because char.init is not 0 in D: :)
assert(tempBuffer[name.length + 1] == '\xff');
Ali
On 11/30/2013 07:58 AM, Dicebot wrote:
> char[] name = "alpha".dup;
> mktemp(name.ptr);
>
> D literals are zero-terminated so toStringz is only needed if you want
> to pass to C function slice of literal or some runtime input.
However, I doubt that .dup copies that '\0' character. Although the
I've run into an interesting little issue with respect to std.math.atan2.
This is used to calculate the "argument" of complex numbers, that is, the angle
in polar coordinates. atan2(y, x) gives the argument of the complex number x + iy.
Now, theoretically, atan2 ought to return a value in the
For the two first ones, I would use an alias:
alias GetCurrentThreadId pthread_self;
alias void * pthread_handler_t;
The third one is a function pointer alias:
alias void * function (void *) pthread_handler;
For the last one, I am not sure, being rusty with the C preprocessor
rule
Just doing these by eyeball...
On Saturday, 30 November 2013 at 14:53:35 UTC, Gary Willoughby
wrote:
#define pthread_self() GetCurrentThreadId()
That's simply
alias pthread_self = GetCurrentThreadId;
#define pthread_handler_t void * __cdecl
This depends on the text replacement and won't
I am terribly sorry, this was a completely lazy question.
So far, I couldn't reproduce the problem in a small example. I'll look
deeper into this before posting again about it.
LMB
On Sat, Nov 30, 2013 at 12:07 PM, Shammah Chancellor
wrote:
> On 2013-11-30 13:39:15 +, Leandro Motta Barro
On Saturday, 30 November 2013 at 15:59:38 UTC, Adam D. Ruppe
wrote:
This is because mktemp needs to write to the string.
Ah disregard my post then, I thought it is yet another C function
that misses `const` in signature :)
On Saturday, 30 November 2013 at 15:48:28 UTC, Nordlöw wrote:
/home/per/Work/justd/fs.d(1042): Error: function
core.sys.posix.stdlib.mktemp (char*) is not callable using
argument types (immutable(char)*)
This is because mktemp needs to write to the string. From
mktemp(3):
The last six
On Saturday, 30 November 2013 at 15:48:28 UTC, Nordlöw wrote:
I think I've read somewhere that string literals (`const` or
`immutable`) are implicitly convertible to zero
(null)-terminated strings.
AFAIR, this should work:
char[] name = "alpha".dup;
mktemp(name.ptr);
D literals are zero-term
I'm struggling to call mktemp in D:
import core.sys.posix.stdlib;
import std.string: toStringz;
auto name = "alpha";
auto tmp = mktemp(name.toStringz);
but I can't figure out how to use it so DMD complains:
/home/per/Work/justd/fs.d(1042): Error: function
core.sys.posix.std
I'm porting some C headers and wondered how would i convert the
following to D:
#define pthread_self() GetCurrentThreadId()
#define pthread_handler_t void * __cdecl
typedef void * (__cdecl *pthread_handler)(void *);
#define set_timespec_nsec(ABSTIME,NSEC) { \
GetSystemTimeAsFileTime(&((ABST
On 2013-11-30 13:39:15 +, Leandro Motta Barros said:
Hello,
I my FewDee game prototyping library (https://bitbucket.org/lmb/fewdee)
I ignored most of the usual reccomendations like "be careful with the
GC, it's slow" and "associative arrays are buggy in D, so avoid them".
I just used wha
Hello,
I my FewDee game prototyping library (https://bitbucket.org/lmb/fewdee) I
ignored most of the usual reccomendations like "be careful with the GC,
it's slow" and "associative arrays are buggy in D, so avoid them". I just
used whatever I found convenient to have my stuff running with minimal
On Saturday, 30 November 2013 at 08:35:23 UTC, Frustrated wrote:
I need to pass around some objects(specifically int[]) that may
be used by several other objects at the same time. While I
could clone these and free them when the parent object is done
this wastes memory for no real reason except
Frustrated:
I need to pass around some objects(specifically int[]) that may
be used by several other objects at the same time. While I
could clone these and free them when the parent object is done
this wastes memory for no real reason except ease of use.
Since many objects may contain a ptr
I need to pass around some objects(specifically int[]) that may
be used by several other objects at the same time. While I could
clone these and free them when the parent object is done this
wastes memory for no real reason except ease of use.
Since many objects may contain a ptr to the array,
29 matches
Mail list logo