www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to translate this to D: const char *const* someConstPtr;

reply "ParticlePeter" <ParticlePeter gmx.de> writes:

const char *const* someConstPtr;
Error: no identifier for declarator char*
Error: declaration expected, not '*'

How would I translate this properly to d?

Cheers, PP
May 09 2015
next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
The second const isn't needed in D, the first one will carry 
through for it too.

const char* in D is equivalent to that C declaration.

const(char)* in D is what const char* in C would be.
May 09 2015
parent "ParticlePeter" <ParticlePeter gmx.de> writes:
That was fast, thanks :-)
May 09 2015
prev sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 05/09/2015 04:18 PM, ParticlePeter wrote:

 const char *const* someConstPtr;
Disecting: 1) const char : There are these chars that cannot be modified 2) * : There are these pointers to such const chars. 3) const: Those pointers cannot point to anything else 4) * : There are these pointers that can point to previously described pointers. The following are the D equivalents, adding more at each step: 1) const(char) 2) const(char)* 3) const(const(char)*) 4) const(const(char)*)* As Adam Ruppe said, the first const (the inner-most in the D version) is redundant: const(char*)* Ali
May 09 2015