diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-03-19 01:10:28 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-03-19 01:14:06 +0100 |
commit | 274fe375264e1767a8dcaea06eaa5d6735e32e37 (patch) | |
tree | 55a799daf18cd9dff760ddaefcd6c1d413c8c26f /src/sciteco.h | |
parent | 735b4c4b743a774c5d53ab6a8e10f0f8308a925b (diff) | |
download | sciteco-274fe375264e1767a8dcaea06eaa5d6735e32e37.tar.gz |
rewritten CHR2STR() using compound statement
* fixes compilation on g++ 4.7 where compound literals are suddenly
temporaries (from which you cannot get a pointer)
* the compound statement (also GCC extension) should ensure that
the string is allocated on the stack with automatic lifetime
Diffstat (limited to 'src/sciteco.h')
-rw-r--r-- | src/sciteco.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/sciteco.h b/src/sciteco.h index 84c9775..a1e2d4b 100644 --- a/src/sciteco.h +++ b/src/sciteco.h @@ -63,7 +63,12 @@ extern sig_atomic_t sigint_occurred; #define IS_SUCCESS(X) ((X) < 0) #define IS_FAILURE(X) (!IS_SUCCESS(X)) -#define CHR2STR(X) ((gchar []){X, '\0'}) +/* + * NOTE: compound literals are temporaries beginning with + * g++ 4.7 + */ +#define CHR2STR(X, ...) \ + ({gchar str[] = {(X), ##__VA_ARGS__, '\0'}; str;}) namespace String { |