NOTICE: Our Community is moving. Get more information.
Customer asks: Is it possible to compile a Visual COBOL native program with Target CPU as AnyCPU? I know it is possible for .NET support, but I am not using it. I read some info about ILTARGET directive, but it is only available for .NET. Is this correct?
The TargetCPU anyCPU option is only available for managed code applications that target the .NET Framework.
Managed code applications are generated as MSIL object code which is the Microsoft Intermediate Language format. Although these are generated as .EXE and .DLL assemblies they are not in an executable format but are instead in an intermediate format that are actually compiled as necessary when they are run.
Because of this you can set the TargetCPU in these files so the .NET compiler knows how to generate the code at run-time.
By setting this to anyCPU, when you run these assemblies on a 32-bit system they will be generated as 32-bit executables and if run on a 64-bit system then they will be generated as 64-bit executables.
You cannot do this with native code applications as the object code format for the .EXE and .DLLs are determined at compile time and not at run-time so you must either compile them as 32-bit (x86) or 64-bit (x64).
If you compile them as 32-bit then they can run under either a 32-bit OS or a 64-bit OS but if you compile them as 64-bit then they can only run under a 64-bit OS.
The directive to compile a Visual COBOL native program as 64-bit is P64.