const char* or const(char)* when porting C headers?
Benjamin Thaut
code at benjamin-thaut.de
Sun Dec 22 08:45:12 PST 2013
Am 22.12.2013 17:02, schrieb Gary Willoughby:
> On Sunday, 22 December 2013 at 15:49:43 UTC, Gary Willoughby wrote:
>
>> Thanks, that makes sense. But how would i port this parameter:
>
> and these:
>
> CONST84 char **tablePtr = ?
> CONST84 char ***argvPtr = ?
In C/C++ the const always applies to whatever is left of it. If there is
nothing left of it, it applies to what is right to it.
So
"const char**" is equivalent to "char const **". That means the only
part that is const is the char. In D const applies to whatever is inside
the parantheses.
So the equivalent in D would be
const(char)** and const(char)***
If you have something like the following in C:
const char * const
the D equivalent would be
const(char*)
Note that the star is included in the parantheses here, because the
pointer is const to, not only the data it points to.
the D type: const(char**) would be equivalent to C: char const * const *
const. (But you won't ever needs this)
Kind Regards
Benjamin Thaut
More information about the Digitalmars-d-learn
mailing list