From 7b543fb53a27dabb87f615f5d44112f3f9204fe9 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Fri, 7 Apr 2017 17:52:51 +0200 Subject: [PATCH] Add note. --- m-string.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/m-string.h b/m-string.h index 208e4b07..db83c679 100644 --- a/m-string.h +++ b/m-string.h @@ -689,12 +689,15 @@ string_in_str(string_t v, FILE *f) /* Use of Compound Literals to init a constant string. 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 : #define STRING_CTE(s) \ ((const string_t){{.size = sizeof(s)-1, .alloc = sizeof(s), \ .ptr = s}}) which produces faster code. + Note: This code doesn't work with C++ (use of c99 feature + of recursive struct definition) */ #define STRING_CTE(s) \ ((const string_t){{.size = sizeof(s)-1, .alloc = sizeof(s), \