]> git.draconx.ca Git - cdecl99.git/blobdiff - src/cdecl.h
Port to use getline.h from dxcommon.
[cdecl99.git] / src / cdecl.h
index 97f39bca800d8b49fb9be56daeccc5a806798fff..39902f5607e35c3c9365a921fe9ffe71a13613db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2011, 2021, 2023 Nick Bowler
+ * Copyright © 2011, 2021, 2023-2024 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
 #ifndef CDECL_H_
 #define CDECL_H_
 
-#include <stddef.h>
-#include <stdint.h>
+#include <stddef.h> /* for size_t */
+
+#if __GNUC__
+#  define CDECL__INLINE __inline
+#else
+#  define CDECL__INLINE inline
+#endif
 
 /* Compatibility typedefs */
 #if HAVE__BOOL
@@ -28,6 +33,14 @@ typedef _Bool cdecl_bool;
 typedef signed char cdecl_bool;
 #endif
 
+#if HAVE_UNSIGNED_LONG_LONG_INT
+typedef unsigned long long cdecl_uintmax;
+#elif HAVE_UNSIGNED___INT64
+typedef unsigned __int64 cdecl_uintmax;
+#else
+typedef unsigned long cdecl_uintmax;
+#endif
+
 /* Declaration specifier kinds. */
 enum {
        CDECL_SPEC_TYPE = 256,
@@ -92,7 +105,7 @@ struct cdecl {
                        } pointer;
                        struct cdecl_array {
                                char *vla;
-                               uintmax_t length;
+                               cdecl_uintmax length;
                        } array;
                        struct cdecl_function {
                                struct cdecl *parameters;
@@ -109,12 +122,12 @@ void cdecl_free(struct cdecl *decl);
 size_t cdecl_explain(char *buf, size_t n, struct cdecl *decl);
 size_t cdecl_declare(char *buf, size_t n, struct cdecl *decl);
 
-static inline int cdecl_spec_kind(const struct cdecl_declspec *spec)
+static CDECL__INLINE int cdecl_spec_kind(const struct cdecl_declspec *spec)
 {
        return spec->type & ~(CDECL_SPEC_TYPE-1u);
 }
 
-static inline int cdecl_is_abstract(const struct cdecl_declarator *d)
+static CDECL__INLINE int cdecl_is_abstract(const struct cdecl_declarator *d)
 {
        while (d->child)
                d = d->child;