Skip to content

Commit

Permalink
Merge pull request #357 from v1993/vs-fix
Browse files Browse the repository at this point in the history
Use the appropriate version of alignof
  • Loading branch information
recp authored Dec 1, 2023
2 parents c6e58bd + 45cf471 commit 6e1d6d5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions include/cglm/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#ifndef cglm_types_h
#define cglm_types_h

#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
# include <stdalign.h>
#endif

#if defined(_MSC_VER)
/* do not use alignment for older visual studio versions */
# if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
Expand Down Expand Up @@ -57,8 +61,16 @@
# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr)
#endif

#define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
((type*)CGLM_ASSUME_ALIGNED((expr), alignof(type)))
#elif defined(_MSC_VER)
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof(type)))
#else
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
#endif

typedef int ivec2[2];
typedef int ivec3[3];
Expand Down

0 comments on commit 6e1d6d5

Please sign in to comment.