Skip to content

Commit

Permalink
Use alignas() in C++11
Browse files Browse the repository at this point in the history
The previous macro test only detected C11 and failed in modern C++, which
actually goes one step further and makes `alignas` a keyword. It's not clear
that this actually improves the situation with respect to Cyan4973#543, but it should
be slightly more correct in some sense.
  • Loading branch information
felixhandte committed Jul 22, 2021
1 parent 6853ddc commit eff9685
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,9 +915,12 @@ struct XXH64_state_s {
XXH64_hash_t reserved64; /*!< Reserved field. Do not read or write to it, it may be removed. */
}; /* typedef'd to XXH64_state_t */

#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11+ */
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* >= C11 */
# include <stdalign.h>
# define XXH_ALIGN(n) alignas(n)
#elif defined(__cplusplus) && (__cplusplus >= 201103L) /* >= C++11 */
/* In C++ alignas() is a keyword */
# define XXH_ALIGN(n) alignas(n)
#elif defined(__GNUC__)
# define XXH_ALIGN(n) __attribute__ ((aligned(n)))
#elif defined(_MSC_VER)
Expand Down

0 comments on commit eff9685

Please sign in to comment.