Skip to content

Commit 20e1c43

Browse files
bjudebrycelelbach
authored andcommitted
Handle MSVC's definition of __cplusplus
MSVC doesnt define __cplusplus correctly unless a compiler flag is passed (/Zc:__cplusplus) but _MSVC_LANG is defined correctly. To avoid users needing to pass an extra compile flag, I suggest we handle it in the cpp_dialect.h file
1 parent 4b55818 commit 20e1c43

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

thrust/detail/config/cpp_dialect.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,24 @@
1616

1717
#pragma once
1818

19-
#if __cplusplus < 201103L
19+
#ifdef _MSC_VER
20+
#define THRUST_CPP_VER _MSVC_LANG
21+
#else
22+
#define THRUST_CPP_VER __cplusplus
23+
#endif
24+
25+
#if THRUST_CPP_VER < 201103L
2026
#define THRUST_CPP03
2127
#define THRUST_CPP_DIALECT 2003
22-
#elif __cplusplus < 201402L
28+
#elif THRUST_CPP_VER < 201402L
2329
#define THRUST_CPP11
2430
#define THRUST_CPP_DIALECT 2011
25-
#elif __cplusplus < 201703L
31+
#elif THRUST_CPP_VER < 201703L
2632
#define THRUST_CPP14
2733
#define THRUST_CPP_DIALECT 2014
2834
#else
2935
#define THRUST_CPP17
3036
#define THRUST_CPP_DIALECT 2017
3137
#endif
3238

39+
#undef THRUST_CPP_VER

0 commit comments

Comments
 (0)