Add note.
This commit is contained in:
1 parent
15e8a7b7d7
commit
7b543fb53a
1 file changed
+4
-1
+4
-1
@@ -689,12 +689,15 @@ string_in_str(string_t v, FILE *f)
|
|||||||
|
|
||||||
/* Use of Compound Literals to init a constant string.
|
/* Use of Compound Literals to init a constant string.
|
||||||
NOTE: The use of the additional structure layer is to ensure
|
NOTE: The use of the additional structure layer is to ensure
|
||||||
that the pointer to char is properly aligned to an int.
|
that the pointer to char is properly aligned to an int (this
|
||||||
|
is a needed asumption by string_hash).
|
||||||
Otherwise it could have been :
|
Otherwise it could have been :
|
||||||
#define STRING_CTE(s) \
|
#define STRING_CTE(s) \
|
||||||
((const string_t){{.size = sizeof(s)-1, .alloc = sizeof(s), \
|
((const string_t){{.size = sizeof(s)-1, .alloc = sizeof(s), \
|
||||||
.ptr = s}})
|
.ptr = s}})
|
||||||
which produces faster code.
|
which produces faster code.
|
||||||
|
Note: This code doesn't work with C++ (use of c99 feature
|
||||||
|
of recursive struct definition)
|
||||||
*/
|
*/
|
||||||
#define STRING_CTE(s) \
|
#define STRING_CTE(s) \
|
||||||
((const string_t){{.size = sizeof(s)-1, .alloc = sizeof(s), \
|
((const string_t){{.size = sizeof(s)-1, .alloc = sizeof(s), \
|
||||||
|
|||||||
Reference in new issue
Block a user