Immutable cannot be casted to const when using pointers

Artur Skawina art.08.09 at gmail.com
Tue Apr 8 14:34:47 PDT 2014


On 04/08/14 23:05, Jeroen Bollen wrote:
> For some reason this code doesn't work...
> 
> module app;
> 
> void main() {
>     immutable char var = 'a';
>     immutable(char)* varPtr = &var;
>     test(&varPtr);
> }
> 
> void test(immutable(char)** param) {
>     test2(param);
> }
> 
> void test2(const(char)** test2) {
>     
> }
> 
> It'll give you " Error: function app.test2 (const(char)** test2) is not callable using argument types (immutable(char)**)", which makes no sense as if a function requests a constant variable, immutable should suffice.

   void test2(const(char)** test2) {
      static char b = 'b';
      *test2 = &b;
   }

artur


More information about the Digitalmars-d mailing list