On Friday, 4 May 2018 at 07:57:26 UTC, Uknown wrote:
On Friday, 4 May 2018 at 07:49:02 UTC, Robert M. Münch wrote:
I have a static C++ and can't make it to get a correct binding
for one function:
DMD: public: unsigned int __cdecl b2d::Context2D::_begin(class
b2d::Image & __ptr64,class
On Friday, 4 May 2018 at 07:49:02 UTC, Robert M. Münch wrote:
I have a static C++ and can't make it to get a correct binding
for one function:
DMD: public: unsigned int __cdecl b2d::Context2D::_begin(class
b2d::Image & __ptr64,class b2d::Context2D::InitParams const *
__ptr64 const) __ptr64
I have a static C++ and can't make it to get a correct binding for one
function:
DMD: public: unsigned int __cdecl b2d::Context2D::_begin(class
b2d::Image & __ptr64,class b2d::Context2D::InitParams const * __ptr64
const) __ptr64
LIB: public: unsigned int __cdecl b2d::Context2D::_begin(class
On Wednesday, 14 March 2018 at 22:23:47 UTC, Cecil Ward wrote:
say in C I have a function with a pointer argument
foo( const sometype_t * p )
[...]
That's the secret - I didn't know about the const (T) * thing - I
would never have discovered that ! Many thanks, the missing piece
to the
a mutable pointer from a const one:
const int* c;
const(int)* m = c; /* no problem */
The target of the pointer just has to remain `const`.
[...]
There probably is a tool somewhere to safely create a modifiable object
based on a const object but I'm not sure where to look.
Generally
On Wednesday, March 14, 2018 22:23:47 Cecil Ward via Digitalmars-d-learn
wrote:
> say in C I have a function with a pointer argument
> foo( const sometype_t * p )
>
> I have asked about this D nightmare before. Using the same
> pattern in D or the in argument qualifier as far as I can see
say in C I have a function with a pointer argument
foo( const sometype_t * p )
I have asked about this D nightmare before. Using the same
pattern in D or the in argument qualifier as far as I can see the
value of the pointer is then itself effectively locked made
constant. Without
Hi, I like to print the strings from a C function that returns
const(dchar*), but I can't make the conversion to dstring. I can
convert vice versa by:
dstring text = Hello;
const(dchar)* str = toUTFz!(const(dchar)*)(text);
// passing it to C function prints Hello
However, I don't have the
On Tue, 24 Jun 2014 13:37:41 -0400, Danyal Zia catofdan...@yahoo.com
wrote:
Hi, I like to print the strings from a C function that returns
const(dchar*), but I can't make the conversion to dstring. I can convert
vice versa by:
dstring text = Hello;
const(dchar)* str =
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer
wrote:
const(dchar *)x = ...;
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
-Steve
const(dchar)* x = Hello\0;
dstring text = x[0..x.strlen].idup;
writeln(text);
Error: no property 'strlen' for type 'const(dchar)*'
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer
wrote:
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
strlen is only defined for char, not dchar:
https://github.com/D-Programming-Language/druntime/blob/master/src/core/stdc/string.d#L44
On Tuesday, 24 June 2014 at 18:17:07 UTC, Danyal Zia wrote:
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer
wrote:
const(dchar *)x = ...;
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
-Steve
const(dchar)* x = Hello\0;
dstring text = x[0..x.strlen].idup;
On Tue, 24 Jun 2014 18:17:06 +, Danyal Zia wrote:
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote:
const(dchar *)x = ...;
// assuming 0 terminated dstring text = x[0..x.strlen].idup;
-Steve
const(dchar)* x = Hello\0;
dstring text = x[0..x.strlen].idup;
On Tuesday, 24 June 2014 at 18:34:31 UTC, Chris Cain wrote:
You can do what he said, but you'll have to write your own
strlen function:
something like:
size_t strlen(in dchar* s) pure @system nothrow
{
size_t pos = 0;
dchar term = '\0';
while(s[pos] != term)
On Tue, 24 Jun 2014 14:28:58 -0400, Chris Cain zsh...@gmail.com wrote:
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote:
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
strlen is only defined for char, not dchar:
That seems like a good approach, since then you're not marking things as const
in D that C would consider mutable and therefore be likely to be altered,
breaking D's guarantees. It does make me think that it could be valuable to
include a comment with the original declaration though (at least
creating.
You'll probably have to go with what is _least_ likely to cause bugs and then
let the programmer adjust it as needed.
- Jonathan M Davis
What do you think about translating the C const to D where possible and
then just leave it mutable in all other cases. Then assuming the C code
called, which naturally doesn't go well
with a tool like you're creating. You'll probably have to go with what is
_least_ likely to cause bugs and then let the programmer adjust it as
needed.
- Jonathan M Davis
What do you think about translating the C const to D where possible
On Wednesday, May 16, 2012 10:24:55 Jacob Carlborg wrote:
On 2012-05-16 09:00, Jonathan M Davis wrote:
Probably true. But also, if you're talking about a const pointer to a
mutable value, the constness of the pointer is actually irrelevant to the
caller. The pointer will be copied when the
On 2012-05-16 07:35, Simen Kjaeraas wrote:
That depends. Will the contents be modified?
I have no idea. I'm working on a tool for automatically translating C
headers. I was thinking since I don't know, I better not add any
promises that is not kept.
--
/Jacob Carlborg
On Wednesday, May 16, 2012 08:50:27 Jacob Carlborg wrote:
On 2012-05-16 07:35, Simen Kjaeraas wrote:
That depends. Will the contents be modified?
I have no idea. I'm working on a tool for automatically translating C
headers. I was thinking since I don't know, I better not add any
promises
On 2012-05-16 09:00, Jonathan M Davis wrote:
Probably true. But also, if you're talking about a const pointer to a mutable
value, the constness of the pointer is actually irrelevant to the caller. The
pointer will be copied when the function is called, so it doesn't matter on
whit whether the
On 16/05/2012 09:24, Jacob Carlborg wrote:
On 2012-05-16 09:00, Jonathan M Davis wrote:
Probably true. But also, if you're talking about a const pointer to a
mutable
value, the constness of the pointer is actually irrelevant to the
caller. The
pointer will be copied when the function is
I'm trying to figuring out how to translate const in C to D. I have
these examples:
const int * a;
int * const b;
const int * const c;
const int * const * d;
Which I think should be translated like this:
const(int)* a;
const int* c;
const(int*)* d;
But I don't know how to translate b. I
On 05/15/2012 12:36 PM, Jacob Carlborg wrote:
I'm trying to figuring out how to translate const in C to D. I have
these examples:
const int * a;
int * const b;
const int * const c;
const int * const * d;
Which I think should be translated like this:
const(int)* a;
const int* c;
const(int*)* d
On 2012-05-15 21:50, Ali Çehreli wrote:
Not possible in D. D's const is transitive. If b is const, then what it
points to is also const.
Ali
Then it would be best to not declare that as const?
--
/Jacob Carlborg
On Tue, 15 May 2012 21:58:46 +0200, Jacob Carlborg d...@me.com wrote:
On 2012-05-15 21:50, Ali Çehreli wrote:
Not possible in D. D's const is transitive. If b is const, then what it
points to is also const.
Ali
Then it would be best to not declare that as const?
That depends. Will the
Jesse Phillips jessekphillip...@gmail.com wrote:
simendsjo Wrote:
On 04.03.2011 23:10, Jesse Phillips wrote:
Remember that const/immutable, and other attributes/properties aren't
going to change the ABI so dropping them will be safer then leaving
them.
Thanks. Does this apply to all
Simen kjaeraas Wrote:
Hopefully I'm not wrong on this, but you should even be able to change
the type as long as the size is the same. So instead of int you could
use uint or byte[8]... granted the library will still interpret it as
int. And of course that is assuming you are on a
I'm not quite sure how to wrap c's const. This page,
http://www.digitalmars.com/d/2.0/htomodule.html, says:
D has const as a type modifier.
void foo(const int *p, char *const q);
becomes:
void foo(const int* p, const char* q);
But D's const is transitive - there are no const
On 04.03.2011 23:10, Jesse Phillips wrote:
simendsjo Wrote:
So all const modifiers should be dropped everywhere..?
And should the const be dropped here?
struct somestruct {
const struct otherstruct;
}
All in all the real answer comes down to, is the data modified. Since C makes
no
simendsjo Wrote:
On 04.03.2011 23:10, Jesse Phillips wrote:
Remember that const/immutable, and other attributes/properties aren't going
to change the ABI so dropping them will be safer then leaving them.
Thanks. Does this apply to all uses of const, or just complex members?
Hopefully
32 matches
Mail list logo