Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29252 Diskussionen

Single source INTEGER declarations for 32-bit and 64-bit builds

schulzey
Neuer Beitragender I
656Aufrufe

If I want to maintain a single set of source code for 32-bit and 64-bit builds, what is the best way to declare INTEGER variables that are automatically 4 bytes for 32-bit and 8 bytes for 64-bit? Should I use:

INTEGER (INT_PTR) MyInt
or
INTEGER (KIND=INT_PTR_KIND()) MyInt

or are they the same? Is there a better way to declare MyInt?

0 Kudos
1 Antworten
IanH
Geehrter Beitragender III
656Aufrufe

I like to use C_INTPTR_T from ISO_C_BINDING.  It won't trigger standard conformance warnings.

This assumes that a pointer in C has the relevant bitness.  In the segmented memory days things weren't always so straight forward.

Antworten