Skip to content

Commit

Permalink
Add alignof wrapper for old compilers.
Browse files Browse the repository at this point in the history
Older versions of MSVC don't support C++11's alignof(), but they do
support __alignof() which functions identically.

Likewise, XL C/C++ versions that predate xlclang/xlclang++ only
support __alignof__() (and optionally __alignof()).

Signed-off-by: Younes Manton <ymanton@ca.ibm.com>
  • Loading branch information
ymanton committed Nov 9, 2020
1 parent 4e066a5 commit c798177
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include_core/omrcomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,4 +601,12 @@ typedef struct U_128 {
#define OMR_LOG_POINTER_SIZE 2
#endif /* defined(OMR_ENV_DATA64) */

#if defined(_MSC_VER) && (1900 > _MSC_VER) /* MSVC versions prior to Visual Studio 2015 (14.0) */
#define OMR_ALIGNOF(x) __alignof(x)
#elif defined(__IBMC__) || defined(__IBMCPP__) /* XL C/C++ versions prior to xlclang/xlclang++ */
#define OMR_ALIGNOF(x) __alignof__(x)
#else /* All other compilers that support C11 and C++11 */
#define OMR_ALIGNOF(x) alignof(x)
#endif /* defined(_MSC_VER) && (1900 > _MSC_VER) */

#endif /* OMRCOMP_H */

0 comments on commit c798177

Please sign in to comment.