Skip to content

Commit

Permalink
Added more safety checks to safebool.h
Browse files Browse the repository at this point in the history
  • Loading branch information
DerjenigeUberMensch committed Sep 8, 2024
1 parent b5ec35b commit 1f36b1a
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions include/safebool.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#ifndef __SAFE__BOOL__H__
#define __SAFE__BOOL__H__
/* prevent redefinitions of header file */
#ifndef _STDBOOL_H
#define _STDBOOL_H
#endif

/* undef defs */
#ifdef bool
Expand Down Expand Up @@ -32,17 +36,29 @@
#endif


typedef enum { false, true } booll;
typedef enum { False, True } boolc;
#if !defined(__cplusplus)

/*
* if not defined then must be c90 or c89
*/
typedef enum { false, true } booll;
typedef enum { False, True } boolc;

#if !defined(__STDC_VERSION__)
typedef enum { false, true } bool;
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
/* true and false are keywords */
#elif !defined(__STDC_VERSION__)
/*
* if not defined then must be c90 or c89
*/
typedef enum { false, true } bool;
#else
typedef _Bool bool;
#endif
#else
typedef _Bool bool;
typedef bool _Bool;
#endif


#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined (1)
#endif

/* __H__ */
#endif

0 comments on commit 1f36b1a

Please sign in to comment.