File tree Expand file tree Collapse file tree
src/steamnetworkingsockets Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,14 +200,26 @@ struct iovec
200200
201201// likely() and unlikely(). Branch hints
202202// This is an idiom from the linux kernel
203- #if defined( __GNUC__) || (defined(__has_builtin) && __has_builtin(__builtin_expect))
203+ #ifdef __GNUC__
204204 #ifndef likely
205205 #define likely (x ) __builtin_expect (!!(x), 1 )
206206 #endif
207207 #ifndef unlikely
208208 #define unlikely (x ) __builtin_expect (!!(x), 0 )
209209 #endif
210210#else
211+ // Nested check avoids MSVC preprocessor parse error (C1012) when
212+ // __has_builtin(...) appears in a single #if expression alongside ||.
213+ #ifdef __has_builtin
214+ #if __has_builtin(__builtin_expect)
215+ #ifndef likely
216+ #define likely (x ) __builtin_expect (!!(x), 1 )
217+ #endif
218+ #ifndef unlikely
219+ #define unlikely (x ) __builtin_expect (!!(x), 0 )
220+ #endif
221+ #endif
222+ #endif
211223 #ifndef likely
212224 #define likely (x ) (x)
213225 #endif
You can’t perform that action at this time.
0 commit comments