Skip to content

Commit 374adbf

Browse files
authored
Fix: inline static warnings with C++23 modules (#287)
The fix just detects the presence of a C++ compiler and uses `inline` instead of `inline static` as a function prefix. This issue is almost identical to this issue in "imgui" ocornut/imgui#8682
1 parent 7f2899a commit 374adbf

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

include/stringzilla/types.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,23 +153,30 @@
153153
* - `SZ_DYNAMIC` is used for functions that are part of the public API, but are dispatched at runtime.
154154
* - `SZ_EXTERNAL` is used for third-party libraries that are linked dynamically.
155155
*/
156+
157+
#if defined(__cplusplus)
158+
#define SZ_C_INLINE inline
159+
#else
160+
#define SZ_C_INLINE inline static
161+
#endif
162+
156163
#if SZ_DYNAMIC_DISPATCH
157164
#if defined(_WIN32) || defined(__CYGWIN__)
158165
#define SZ_DYNAMIC __declspec(dllexport)
159166
#define SZ_EXTERNAL __declspec(dllimport)
160-
#define SZ_PUBLIC inline static
161-
#define SZ_INTERNAL inline static
167+
#define SZ_PUBLIC SZ_C_INLINE
168+
#define SZ_INTERNAL SZ_C_INLINE
162169
#else
163170
#define SZ_DYNAMIC extern __attribute__((visibility("default")))
164171
#define SZ_EXTERNAL extern
165-
#define SZ_PUBLIC __attribute__((unused)) inline static
166-
#define SZ_INTERNAL __attribute__((always_inline)) inline static
172+
#define SZ_PUBLIC __attribute__((unused)) SZ_C_INLINE
173+
#define SZ_INTERNAL __attribute__((always_inline)) SZ_C_INLINE
167174
#endif // _WIN32 || __CYGWIN__
168175
#else
169-
#define SZ_DYNAMIC inline static
176+
#define SZ_DYNAMIC SZ_C_INLINE
170177
#define SZ_EXTERNAL extern
171-
#define SZ_PUBLIC inline static
172-
#define SZ_INTERNAL inline static
178+
#define SZ_PUBLIC SZ_C_INLINE
179+
#define SZ_INTERNAL SZ_C_INLINE
173180
#endif // SZ_DYNAMIC_DISPATCH
174181

175182
/**

0 commit comments

Comments
 (0)