diff options
author | Thomas Haller <thaller@redhat.com> | 2017-12-13 08:17:07 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-12-13 08:17:07 +0100 |
commit | 8f0c163245883ed1e1fb1fb9b7bc65443e5ff01f (patch) | |
tree | fe69f835512f6de5bf70fe5365dcc1a912801995 /po | |
parent | 9c7f04ad328f82e5472d8f948b2d60e8218d9cc4 (diff) |
basic/macros: add STRLEN() to get length of string literal as constant expression
While the compiler likely optimizes strlen(x) for string literals,
it is not a constant expression.
Hence,
char buffer[strlen("OPTION_000") + 1];
declares a variable-length array. STRLEN() can be used instead
when a constant espression is needed.
It's not entirely identical to strlen(), as STRLEN("a\0") counts 2.
Also, it only works with string literals and the macro enforces
that the argument is a literal.
Diffstat (limited to 'po')
0 files changed, 0 insertions, 0 deletions