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

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

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?

2 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

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.

发表评论

登录添加评论。还不是成员?立即加入