- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I understand that 'portable' or standard conforming code uses specification statements such as REAL(DOUBLE) rather than REAL*8. However, if I wish to replace all my INTEGER*4 specifications, I am left with a bewidering set of choices, such as INTEGER(LONG), INTEGER(UINT), INTEGER(SINT) etc. Here is an example of what's available from DFWINTY: (I use CVF 6.6C)
integer, parameter :: POINTER_LEN = INT_PTR_KIND() ! 4 for WIN32 systems
integer, parameter :: HANDLE = POINTER_LEN ! INTEGER(4/8)
integer, parameter :: DWORD = 4 ! INTEGER(4)
integer, parameter :: ULONG = 4 ! INTEGER(4)
integer, parameter :: LONG = 4 ! INTEGER(4)
integer, parameter :: UINT = 4 ! INTEGER(4)
! The S (for signed) is to avoid conflict with the INT intrinsic
integer, parameter :: SINT = 4 ! INTEGER(4)
integer, parameter :: ENUM = 4 ! INTEGER(4)
integer, parameter :: BOOL = 4 ! INTEGER(4)
Why are there so many partameterised choices for thelength '4'? Which one should I use?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So if you are declaring things for use with Win32 API calls, then use the appropriate named constant that matches the MS documentation. HANDLE is a particularly important one to get right as it is different between 32 and 64-bit Windows.
If you're not calling Win32 API code but are calling C, then use the kind constants defined in ISO_C_BINDING.
If you have a need for an integer that will hold a particular number of decimal digits, ise the SELECTED_INT_KIND intrinsic to select it, though I don't recommend using a value lower than 9 for the argument unless required as use of smaller than 32-bit integers can slow down code. This is useful when you want more than 9 digits.
If you want an integer that holds an address, use INT_PTR_KIND() to get that value, or from ISO_C_BINDING, C_PTR.
Otherwise, if all you want is the default integer kind, just say INTEGER with no kind.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page