GCC warning, whom to blame?

Matthias Clasen mclasen at redhat.com
Thu Mar 10 13:43:31 UTC 2005


On Thu, 2005-03-10 at 14:33 +0100, Ralf Ertzinger wrote:
> Hi.
> 
> I am getting a GCC error while compiling a package (which is not part of FC),
> and I'd like to know if this is a gcc4 bug (which I think it is):
> 
> The compile dies with:
> 
> configfile.c:87:73: error: macro "read" passed 4 arguments, but takes just 3
> configfile.c: In function 'xmms_cfg_read_value':
> configfile.c:86: warning: return makes integer from pointer without a cast
> configfile.c:95:66: error: macro "read" passed 4 arguments, but takes just 3
> configfile.c: In function 'xmms_cfg_write_value':
> configfile.c:94: warning: statement with no effect
> 
> 
> The line in question reads:
> 
> 82 gboolean xmms_cfg_read_value(ConfigFile * config_file,
> 83                              const gchar * section, const gchar * key,
> 84                              XmmsCfgValueType value_type, gpointer * value)
> 85 {
> 86     return xmms_cfg_value_type_func[value_type].read(config_file,
> 87                                                      section, key, value);
> 88 }
> 
> I think glibc implemets the read system call as a macro, and GCC tries to
> apply this macro to the .read part above. Am I correct? If yes, is GCC
> correct in doing this?
> 

Posix explicitly allows this. Using standard function names in that way
is just a bad idea, like to using C++ keywords. One way to work around
this is to use (read) instead of read (the parens prevent macro
expansion). 

Matthias




More information about the fedora-devel-list mailing list