Skip to content

Instantly share code, notes, and snippets.

@laruence
Created July 1, 2014 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laruence/2b4ca659b6eee2b81de5 to your computer and use it in GitHub Desktop.
Save laruence/2b4ca659b6eee2b81de5 to your computer and use it in GitHub Desktop.
typedef struct {
long gc;
long h;
int len;
char val[1];
} zend_string;
#define STATIC_STR_INIT(name, str, size) \
struct { \
long gc; \
long h; \
int len; \
char val[(size)]; \
} (name) = {0, 0, (size), (str) };
int main (int argc, char **argv) {
STATIC_STR_INIT(name, "laruence", sizeof("laruence"));
zend_string *p = (zend_string*)&name;
printf("%d:%s\n", p->len, p->val);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment