Skip to content

Commit 1670d54

Browse files
nk0073bluca
authored andcommitted
Problem: MSVC C23 bool typedef causes an error
Soltion: only add bool if the standard is lower than C23
1 parent 1786a2d commit 1670d54

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

include/czmq_prelude.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,17 +529,20 @@ typedef struct {
529529
// That's it about the randof() macro definition...
530530

531531

532-
// Windows MSVS doesn't have stdbool
533-
#if (defined (_MSC_VER))
534-
# if (!defined (__cplusplus) && (!defined (true)))
535-
# define true 1
536-
# define false 0
537-
typedef char bool;
532+
// Fallback for booleans for pre-C23 C and MSVC builds
533+
#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 202311L
534+
# if (defined (_MSC_VER))
535+
# if (!defined (__cplusplus) && (!defined (true)))
536+
# define true 1
537+
# define false 0
538+
typedef char bool;
539+
# endif
540+
# else
541+
# include <stdbool.h>
538542
# endif
539-
#else
540-
# include <stdbool.h>
541543
#endif
542544

545+
543546
//- A number of POSIX and C99 keywords and data types -----------------------
544547
// CZMQ uses uint for array indices; equivalent to unsigned int, but more
545548
// convenient in code. We define it in czmq_prelude.h on systems that do

0 commit comments

Comments
 (0)