git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/9] gettext.h: Avoid using a non-standard C construct

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Apr 7, 2011, 18:41 UTC
Message-ID
<4D9E056C.1070906@ramsay1.demon.co.uk>

In particular, standard C does not allow a parenthesized string as an array initializer. Some compilers, for example GCC and MSVC, allow this syntax as an extension, but it is (obviously) not a portable construct.

In order to avoid such a construct, for example while initialising the array 'ignore_error' (builtin/add.c line 309), we simply remove the parenthesis from the definition of the N_() macro.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
For example, tcc can not parse this syntax.
Note that sparse issues warnings like the following:
    builtin/add.c:309:1: warning: too long initializer-string for \
        array of char
which is actually a bug in sparse that is tickled by a parenthesized
string initializer (it doesn't determine the correct size of the
string). Again I have a patch ...
 gettext.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gettext.h b/gettext.h
index 1b253b7..24d9182 100644
--- a/gettext.h
+++ b/gettext.h
@@ -35,6 +35,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
 }
 
 /* Mark msgid for translation but do not translate it. */
-#define N_(msgid) (msgid)
+#define N_(msgid) msgid
 
 #endif
-- 
1.7.4
Next: Jonathan Nieder
Message 1 of 5 in “gettext.h: Avoid using a non-standard C construct”
  1. 6/9 gettext.h: Avoid using a non-standard C constructRamsay Jones, Apr 7, 2011
  2. Jonathan NiederApr 7, 2011
  3. Ævar Arnfjörð BjarmasonApr 10, 2011
  4. Ramsay JonesApr 11, 2011
  5. Junio C HamanoApr 11, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.