In a number of seperate files, the ((unused)) attribute went ignored, causing warnings for these lines: static char bugs_doc[] __attribute__ ((unused)) = "Robin Daugherty"; static char version[] __attribute__ ((unused)) = "hsmdr 1.0 (2003-APR-29)"; But only if the mysql header files are included first: // MySQL client headers #include <mysql/my_global.h> #include <mysql/my_sys.h> #include <mysql/m_string.h> #include <mysql/mysql.h> #include <mysql/mysql_embed.h> #include <mysql/errmsg.h> #include <mysql/my_getopt.h> Moving this block before the two declarations causes warnings to be issued: hsmdr.cpp:48: warning: `char bugs_doc[16]' defined but not used hsmdr.cpp:49: warning: `char version[24]' defined but not used But these warnings are gone if the declaration is first.
Can you provide the preprocessed source file after reading http://gcc.gnu.org/bugs.html.
Created attachment 5388 [details] File With The Warning
Created attachment 5389 [details] File Without The Warning (correct behavior) When compiled with -Wall, this file will produce "defined but not used" warnings only for doc, args_doc, and options. This is correct, because although bugs_doc and version are not used, they have the __unused__ attribute set.
Created attachment 5390 [details] MySQL header file
I have observed this with 3.2.1 and 3.3.2 (made with default options for x86 on Linux). I compile these files with -Wall (I use this option in my Makefiles). I have attached two files, one which causes five warnings, and one which causes only three. The difference between them is that #include <mysql/my_global.h> is before the definitions in the first file, but after them in the second. Let me know if you still want preprocessed sources from me.
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) #define __attribute__(A) #endif There's the cuplrit. Complain to whoever provided this header file.
I made sure this got into MySQL AB's bug tracking system: http://bugs.mysql.com/bug.php?id=2717 Jeremy