summaryrefslogtreecommitdiff
path: root/slang.h
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-04-27 12:36:59 +0800
committerGitHub <noreply@github.com>2023-04-26 21:36:59 -0700
commit3acbe8145c60f4d1e7a180b4602a94269a489df5 (patch)
tree8031e7ca897260ac3ab6d2a920864f3114bc8668 /slang.h
parenta3da31c189a1cc9bdf85a42ac359b8c2777f3550 (diff)
Fix most of the disabled warnings on gcc/clang (#2839)
Diffstat (limited to 'slang.h')
-rw-r--r--slang.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/slang.h b/slang.h
index 1bea9c4be..1fcad0d83 100644
--- a/slang.h
+++ b/slang.h
@@ -299,7 +299,8 @@ convention for interface methods.
#endif
// Use for getting the amount of members of a standard C array.
-#define SLANG_COUNT_OF(x) (sizeof(x)/sizeof(x[0]))
+// Use 0[x] here to catch the case where x has an overloaded subscript operator
+#define SLANG_COUNT_OF(x) (SlangSSizeT(sizeof(x)/sizeof(0[x])))
/// SLANG_INLINE exists to have a way to inline consistent with SLANG_ALWAYS_INLINE
#define SLANG_INLINE inline
@@ -525,11 +526,13 @@ extern "C"
typedef int64_t SlangInt;
typedef uint64_t SlangUInt;
+ typedef int64_t SlangSSizeT;
typedef uint64_t SlangSizeT;
#else
typedef int32_t SlangInt;
typedef uint32_t SlangUInt;
+ typedef int32_t SlangSSizeT;
typedef uint32_t SlangSizeT;
#endif