@@ -57,19 +57,19 @@ typedef const WpStr8 WpStr8RO;
|
|||||||
// Utilises the fact that memcpy returns pointer to dest buffer and that getting
|
// Utilises the fact that memcpy returns pointer to dest buffer and that getting
|
||||||
// address of compound literals is valid in C to create a string on the stack
|
// address of compound literals is valid in C to create a string on the stack
|
||||||
#define wpStr8Lit(STRING) ((WpStr8){.capacity = (sizeof(STRING) - 1) * 2, \
|
#define wpStr8Lit(STRING) ((WpStr8){.capacity = (sizeof(STRING) - 1) * 2, \
|
||||||
.size = sizeof(STRING) - 1, \
|
.size = sizeof(STRING) - 1, \
|
||||||
.buf = memcpy(&((c8 [sizeof(STRING) * 2]){0}), \
|
.buf = memcpy(&((c8 [sizeof(STRING) * 2]){0}), \
|
||||||
STRING, \
|
STRING, \
|
||||||
sizeof(STRING))})
|
sizeof(STRING))})
|
||||||
#define wpStr8LitRo(STRING) ((WpStr8RO){.capacity = sizeof(STRING) - 1, \
|
#define wpStr8LitRo(STRING) ((WpStr8RO){.capacity = sizeof(STRING) - 1, \
|
||||||
.size = sizeof(STRING) - 1, \
|
.size = sizeof(STRING) - 1, \
|
||||||
.buf = (c8 *)STRING})
|
.buf = (c8 *)STRING})
|
||||||
// To be used only when initialising a static storage variable in compilers that don't support
|
// To be used only when initialising a static storage variable in compilers that don't support
|
||||||
// initialisers with the syntax of wpStr8LitRo (e.g. gcc). Should only be used when necessary
|
// initialisers with the syntax of wpStr8LitRo (e.g. gcc). Should only be used when necessary
|
||||||
// and only be assigned to a WpStr8RO variable to avoid any attempt at modifying the string
|
// and only be assigned to a WpStr8RO variable to avoid any attempt at modifying the string
|
||||||
#define wpStr8LitRoInitialiserList(STRING) {.capacity = sizeof(STRING) - 1, \
|
#define wpStr8LitRoInitialiserList(STRING) {.capacity = sizeof(STRING) - 1, \
|
||||||
.size = sizeof(STRING) - 1, \
|
.size = sizeof(STRING) - 1, \
|
||||||
.buf = (c8 *)STRING}
|
.buf = (c8 *)STRING}
|
||||||
#endif // !WP_PLATFORM_CPP
|
#endif // !WP_PLATFORM_CPP
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user