Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Can target CPU setting anyCPU be used for native applications?

Can target CPU setting anyCPU be used for native applications?


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.


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-07-09 15:11
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.