]> git.draconx.ca Git - cdecl99.git/blobdiff - src/cdecl.h
libcdecl: Add _Bool fallback to public header.
[cdecl99.git] / src / cdecl.h
index 20a94f2b2c4bb4a2305a1952045e57d877b51204..97f39bca800d8b49fb9be56daeccc5a806798fff 100644 (file)
@@ -1,18 +1,18 @@
 /*
- *  Copyright © 2011, 2021, 2023 Nick Bowler
+ * Copyright © 2011, 2021, 2023 Nick Bowler
  *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #ifndef CDECL_H_
 #include <stddef.h>
 #include <stdint.h>
 
+/* Compatibility typedefs */
+#if HAVE__BOOL
+typedef _Bool cdecl_bool;
+#else
+typedef signed char cdecl_bool;
+#endif
+
 /* Declaration specifier kinds. */
 enum {
        CDECL_SPEC_TYPE = 256,
        CDECL_SPEC_STOR = 512,
        CDECL_SPEC_QUAL = 1024,
-       CDECL_SPEC_FUNC = 2048,
+       CDECL_SPEC_FUNC = 2048
 };
 
 enum {
@@ -54,7 +61,7 @@ enum {
        CDECL_QUAL_RESTRICT = CDECL_SPEC_QUAL,
        CDECL_QUAL_VOLATILE,
        CDECL_QUAL_CONST,
-       CDECL_FUNC_INLINE = CDECL_SPEC_FUNC,
+       CDECL_FUNC_INLINE = CDECL_SPEC_FUNC
 };
 
 /* Declarator types. */
@@ -63,7 +70,7 @@ enum {
        CDECL_DECL_IDENT,
        CDECL_DECL_POINTER,
        CDECL_DECL_ARRAY,
-       CDECL_DECL_FUNCTION,
+       CDECL_DECL_FUNCTION
 };
 
 struct cdecl {
@@ -89,7 +96,7 @@ struct cdecl {
                        } array;
                        struct cdecl_function {
                                struct cdecl *parameters;
-                               _Bool variadic;
+                               cdecl_bool variadic;
                        } function;
                } u;
        } *declarators;
@@ -107,7 +114,7 @@ static inline int cdecl_spec_kind(const struct cdecl_declspec *spec)
        return spec->type & ~(CDECL_SPEC_TYPE-1u);
 }
 
-static inline _Bool cdecl_is_abstract(const struct cdecl_declarator *d)
+static inline int cdecl_is_abstract(const struct cdecl_declarator *d)
 {
        while (d->child)
                d = d->child;