Thread overview
How to translate this to D: const char *const* someConstPtr;
May 09, 2015
ParticlePeter
May 09, 2015
Adam D. Ruppe
May 09, 2015
ParticlePeter
May 09, 2015
Ali Çehreli
May 09, 2015
Hi,

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
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
That was fast, thanks :-)
May 09, 2015
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