Translating C const

Jonathan M Davis jmdavisProg at gmx.com
Wed May 16 00:00:08 PDT 2012


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 that is not kept.

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 pointer itself is const or not. What matters is whether 
what's being pointed to is const or not. So, if you have a function which 
takes a const pointer to a non-const value, then that's essentially identical 
to one that takes a non-const pointer to a non-const value as far as the 
declarations go - and for declaring extern(C) functions for use in D, that's 
generally all you care about.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list