mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-24 16:11:43 +00:00
libghostty: make sized initialization valid C++
Use an immediately invoked lambda for GHOSTTY_INIT_SIZED in C++ so the macro value-initializes every field before setting the ABI size. The previous C compound literal and designated initializer required compiler extensions in C++17 and C++20. Keep the existing standard compound literal for C callers.
This commit is contained in:
@@ -319,8 +319,17 @@ typedef struct {
|
||||
* opts.trim = true;
|
||||
* @endcode
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#define GHOSTTY_INIT_SIZED(type) \
|
||||
([]() noexcept { \
|
||||
type value{}; \
|
||||
value.size = sizeof(value); \
|
||||
return value; \
|
||||
}())
|
||||
#else
|
||||
#define GHOSTTY_INIT_SIZED(type) \
|
||||
((type){ .size = sizeof(type) })
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return a pointer to a null-terminated JSON string describing the
|
||||
|
||||
Reference in New Issue
Block a user