Hi,

I still get warnings for unused parameters from the hwloc/helper.h
header.  The code to check this attribute is this:

         int square(int arg1 __attribute__ ((__unused__)), int arg2);
         int square(int arg1, int arg2) { return arg2; }

But this results in this conflig.log output:

configure:11129: checking for __attribute__(unused)
configure:11152: gcc -std=gnu99 -c  -Wall -Wunused-parameter -Wundef
-Wno-long-long -Wsign-compare -Wmissing-prototypes -Wstrict-prototypes
-Wcomment -pedantic  conftest.c >&5
conftest.c: In function 'square':
conftest.c:44: warning: unused parameter 'arg1'
conftest.c: At top level:
conftest.c:48: warning: function declaration isn't a prototype
configure:11152: $? = 0
configure:11236: result: yes

AFAIK the correct usage would be:

         int square(int __attribute__ ((__unused__)) arg1, int arg2) {
return arg2; }

I.e. the attribute is between type and name. Also, it needs to be in
the declaration not in the prototype. The output for this code is:

configure:11129: checking for __attribute__(unused)
configure:11151: gcc -std=gnu99 -c  -Wall -Wunused-parameter -Wundef
-Wno-long-long -Wsign-compare -Wmissing-prototypes -Wstrict-prototypes
-Wcomment -pedantic  conftest.c >&5
conftest.c:43: warning: no previous prototype for 'square'
conftest.c:47: warning: function declaration isn't a prototype
configure:11151: $? = 0
configure:11235: result: yes

This results only in a warning that the prototype is missing.

Also, the use of the unused attribute for static functions does not
need a prototype:

         extern int square1(int arg1, int arg2);
         int square1(int arg1 __attribute__ ((__unused__)), int arg2)
{ return arg2; }

         static int __attribute__ ((__unused__)) square2(int arg1, int
arg2) { return arg1 * arg2; }

Results in this output:

configure:11129: checking for __attribute__(unused)
configure:11154: gcc -std=gnu99 -c  -Wall -Wunused-parameter -Wundef
-Wno-long-long -Wsign-compare -Wmissing-prototypes -Wstrict-prototypes
-Wcomment -pedantic  conftest.c >&5
conftest.c:50: warning: function declaration isn't a prototype
configure:11154: $? = 0
configure:11238: result: yes

This is on ubuntu woth this compiler:

$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.4.1-4ubuntu9'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --enable-multiarch --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4
--program-suffix=-4.4 --enable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-objc-gc --disable-werror
--with-arch-32=i486 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)

Regards,
Bert

Reply via email to