[Clfs-dev] vim and UNUSED attribute in trunk

Ken Moffat zarniwhoop73 at googlemail.com
Wed Sep 30 12:24:12 PDT 2009


Trying to build the 20090922 book on x86_64-64, using a system from January,
it fell apart in chapter 6's vim with

buffer.c: In function 'buflist_findpat':
buffer.c:2034: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'UNUSED'
buffer.c: In function 'build_stl_str_hl':
buffer.c:3307: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'UNUSED'
make[1]: *** [objects/buffer.o] Error 1

 After an afternoon of kicking this about, I found the required fix
upstream, within
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.173

 That patch is one of those NOT included in the branch update patches, I guess
because one of the hunks for buffer.c depends on another patch that is also not
in the branch update.  So, I've stripped it down to just the
configury.  With this
added, I've completed chapter 6.

 Posted to the list because I'm still not using git, so I can't fix the book.

ĸen
Submitted By: Ken Moffat <zarniwhoop73 at googlemail dot com>
Date: 2009-09-30
Initial Package Version: 7.2
Upstream Status: From upstream
Origin: Part of ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.173
Description: With the cherry-picking of patches in vim's branch_update-21
I get:

buffer.c: In function 'buflist_findpat':
buffer.c:2034: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'UNUSED'
buffer.c: In function 'build_stl_str_hl':
buffer.c:3307: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'UNUSED'
make[1]: *** [objects/buffer.o] Error 1

 This patch pulls in the configury for this, whilst avoiding the other
changes which
we have happily ignored until now (and which depend in part on other changes).
Rediffed to apply with -p1.  Also attached, in case gmail damages the whitespace
in the inline version.

diff -Naur vim72.orig/src/auto/configure vim72/src/auto/configure
--- vim72.orig/src/auto/configure       2008-07-24 13:40:36.000000000 +0100
+++ vim72/src/auto/configure    2009-09-30 19:59:21.000000000 +0100
@@ -10362,6 +10362,56 @@

 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

+{ $as_echo "$as_me:$LINENO: checking whether __attribute__((unused))
is allowed" >&5
+$as_echo_n "checking whether __attribute__((unused)) is allowed... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+int x __attribute__((unused));
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF
+#define HAVE_ATTRIBUTE_UNUSED 1
+_ACEOF
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 if test "${ac_cv_header_elf_h+set}" = set; then
   { $as_echo "$as_me:$LINENO: checking for elf.h" >&5
 $as_echo_n "checking for elf.h... " >&6; }
diff -Naur vim72.orig/src/config.h.in vim72/src/config.h.in
--- vim72.orig/src/config.h.in  2008-06-21 16:01:41.000000000 +0100
+++ vim72/src/config.h.in       2009-09-30 19:59:21.000000000 +0100
@@ -30,6 +30,9 @@
 /* Define when __DATE__ " " __TIME__ can be used */
 #undef HAVE_DATE_TIME

+/* Define when __attribute__((unused)) can be used */
+#undef HAVE_ATTRIBUTE_UNUSED
+
 /* defined always when using configure */
 #undef UNIX

diff -Naur vim72.orig/src/vim.h vim72/src/vim.h
--- vim72.orig/src/vim.h        2008-08-09 17:03:38.000000000 +0100
+++ vim72/src/vim.h     2009-09-30 19:59:21.000000000 +0100
@@ -262,6 +262,14 @@
 # define __PARMS(x) __ARGS(x)
 #endif

+/* Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
+ * can be used to check for mistakes. */
+#ifdef HAVE_ATTRIBUTE_UNUSED
+# define UNUSED __attribute__((unused))
+#else
+# define UNUSED
+#endif
+
 /* if we're compiling in C++ (currently only KVim), the system
  * headers must have the correct prototypes or nothing will build.
  * conversely, our prototypes might clash due to throw() specifiers and


-- 
After tragedy, and farce, "OMG poneys!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vim-7.2-attribute-1.patch
Type: application/octet-stream
Size: 3630 bytes
Desc: not available
URL: <http://lists.clfs.org/pipermail/clfs-dev-clfs.org/attachments/20090930/a9e8e495/attachment-0001.obj>


More information about the Clfs-dev mailing list