bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] [1.13.90] compilation problems on IRIX


From: Paul Eggert
Subject: Re: [Bug-tar] [1.13.90] compilation problems on IRIX
Date: 04 Nov 2003 17:37:41 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Sergey Poznyakoff <address@hidden> writes:

> Oh, with that patch adding or removing entries to xhdr_tab becomes
> very error-prone (one should always *count* the actual number of
> entries and update the forward). I guess I'd better get rid of the
> forward declaration at all.

You can't get rid of the forward declaration, since that will invalidate
all the code that uses that variable.

You can't move the initializer into the forward declaration, since that
would require you to add forward declarations for every procedure mentioned
in the initializer, which would be a worse maintenance nightmare.

If you don't like counting, then perhaps the simplest thing is to make
xhdr_tab external.  I installed the following patch to do this.
This conforms to the C Standard.  (Weird, huh?)

2003-11-04  Paul Eggert  <address@hidden>

        * src/xheader.c (xhdr_tab): Make it extern, not static, as C89 and
        C99 require this.

Index: src/xheader.c
===================================================================
RCS file: /cvsroot/tar/tar/src/xheader.c,v
retrieving revision 1.8
diff -p -u -r1.8 xheader.c
--- src/xheader.c       3 Nov 2003 23:03:35 -0000       1.8
+++ src/xheader.c       5 Nov 2003 00:13:47 -0000
@@ -36,10 +36,13 @@ struct xhdr_tab
   void (*decoder) (struct tar_stat_info *, char const *);
 };
 
-/* This declaration must specify the number of elements in xhdr_tab,
-   because ISO C99 section 6.9.2 prohibits a tentative definition that
-   has both internal linkage and incomplete type.  */
-static struct xhdr_tab const xhdr_tab[13];
+/* This declaration must be extern, because ISO C99 section 6.9.2
+   prohibits a tentative definition that has both internal linkage and
+   incomplete type.  If we made it static, we'd have to declare its
+   size which is a maintenance pain; if we put its initializer here,
+   we'd have a boatload of forward declarations, which is even more of
+   a maintenance pain.  */
+extern struct xhdr_tab const xhdr_tab[];
 
 static struct xhdr_tab const *
 locate_handler (char const *keyword)
@@ -409,7 +412,7 @@ uname_decoder (struct tar_stat_info *st,
   assign_string (&st->uname, arg);
 }
 
-static struct xhdr_tab const xhdr_tab[] = {
+struct xhdr_tab const xhdr_tab[] = {
   { "atime",   atime_coder,    atime_decoder   },
   { "comment", dummy_coder,    dummy_decoder   },
   { "charset", dummy_coder,    dummy_decoder   },




reply via email to

[Prev in Thread] Current Thread [Next in Thread]