]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
include/uk/arch: Define bool types for C++ compilers
authorStefan Jumarea <stefanjumarea02@gmail.com>
Mon, 23 Sep 2024 12:14:27 +0000 (15:14 +0300)
committerUnikraft Bot <monkey@unikraft.io>
Thu, 31 Oct 2024 13:12:46 +0000 (13:12 +0000)
If compiling using a C++ compiler, `_Bool` is undefined, as it is a C
built-in type and C++ compilers do not recognize it. Define `__bool`,
`__true` and `__false` for C++ compiler as `bool`, `true` and `false`.

Checkpatch-Ignore: REPEATED_WORD
Github-Fixes: #1513
Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1500

include/uk/arch/types.h

index b43dffabbd3bb43bd401f7ccf0bc2a2d6f678439..e0bd80c6c44257f0bb2e87c4ab2692428a82eed9 100644 (file)
@@ -257,9 +257,15 @@ typedef struct {
        __u32 counter;
 } __atomic;
 
+#ifdef __cplusplus
+typedef bool __bool;
+#define __true (true)
+#define __false (false)
+#else
 typedef _Bool __bool;
 #define __true (1)
 #define __false (0)
+#endif /* __cplusplus */
 
 #else /* __ASSEMBLY__ */