The two fragments below compiled and ran as expected using dmd -betterC under Windows.
   string Scrn = "OPO NAM='DspVar1' POS='1,1' VAR=('IntVar1','I');E";
   printf("\nWR_Createtest entered.\n");
   OpStructFstPtr = WR_CreateFormatFile(Scrn);
OpStruct* WR_CreateFormatFile(string parm_Format) {
   import core.stdc.stdio: printf;
   import core.stdc.stdlib: malloc;
   OpStruct* FstOpStructPtr;
   if (parm_Format[0..3] == "OPO"[0..3]) {
      printf("OPO Found.\n");
   } else {
      printf("OPO NOT Found.\n");
   }
   if (parm_Format[$-1..$] == "E"[0..1]) {
      printf("E Found.\n");
   } else {
      printf("E NOT Found.\n");
   }
However, the docs say dynamic arrays are not allowed with betterC, and 'string' implies a dynamic array.
So I expected DMD to complain that my code was invalid.
Any ideas?
 Permalink
Permalink Reply
Reply