Delphi set Assignable Constants True for command line assembly

When building my project using RAD Studio command line, the following error appears: error E2064: the left side cannot be assigned

I know this is related to the Assignable Typed Constants issue and I know where to enable it in the Embaracadero compiler, however I need to set these options outside the compiler.

Now my config file looks like this:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
    <DCC_HppOutput>c:\d64\DCUfiles</DCC_HppOutput>
    <DCC_ObjOutput>c:\d64\DCUfiles</DCC_ObjOutput>
    <DCC_UnitSearchPath>c:\d64\sf\cis;C:\d64\Dcu64;C:\d64\ProkonRibbon;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
    <Icon_MainIcon>Frame_Icon.ico</Icon_MainIcon>
    <DCC_LocalDebugSymbols>true</DCC_LocalDebugSymbols>
    <VerInfo_Release>67</VerInfo_Release>
    <DCC_ImportedDataReferences>false</DCC_ImportedDataReferences>
    <DCC_StrictVarStrings>false</DCC_StrictVarStrings>
    <DCC_Define>_VER7;_VER7;_VER7;_VER7;$(DCC_Define)</DCC_Define>
    <DCC_DcuOutput>c:\d64\Dcu64</DCC_DcuOutput>
    <DCC_ExeOutput>c:\prokon\bin64</DCC_ExeOutput>
    <VerInfo_Keys>CompanyName=;
                FileDescription=;
                FileVersion=2.6.67.0;
                InternalName=;
                LegalCopyright=;
                LegalTrademarks=;
                OriginalFilename=;
                ProductName=;
                ProductVersion=2.6.67.0;
                Comments=23 Jul 2015
    </VerInfo_Keys>
    <VerInfo_Locale>1033</VerInfo_Locale>
    <VerInfo_MinorVer>6</VerInfo_MinorVer>
</PropertyGroup>
<ProjectExtensions>
    <Borland.Personality>Delphi.Personality.12</Borland.Personality>
    <Borland.ProjectType>OptionSet</Borland.ProjectType>
    <BorlandProject>
        <Delphi.Personality/>
    </BorlandProject>
    <ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>

      

Is there a way to set the Assignable Typed Constants property in this file?

+3


source to share


1 answer


Add inside tag <PropertyGroup>

<DCC_WriteableConstants>true</DCC_WriteableConstants>

      

You can also include this setting in your source code using the switch {$J+}

or {$WRITEABLECONST ON}

. This would be the most preferred option as the code cannot be compiled without it.



Another advantage of using a compiler directive in your code is that you can selectively use the typed constants you write instead of all the typed constants you write.

const
  {$WRITEABLECONST ON}
  x: integer = 1;
  {$WRITEABLECONST OFF}
  y: integer = 2;

begin
  writeln(x); // -> 1
  x := 3;
  writeln(x); // -> 3
  y := 4; // does not compile
end.

      

+4


source







All Articles