#define const before including system headers?

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

 



The following code snippit:

#define const
#include <stdlib.h>
 
int foo(const void *a, const void *b)
{
  return 0;
}
 
int main(void)
{
  qsort(NULL, 0, 0, foo);
  return 0;
}

produces the following warning on gcc 3.3.3:

$ gcc bar.c
bar.c: In function `main':
bar.c:11: warning: passing arg 4 of `qsort' from incompatible pointer type

A little bit odd, since I would have expected the definition of const
to nothingness to remove the consts from the system headers as well as
the local source file, preventing warnings from coming up.  Sure
enough, passing this snippit through cpp results in qsort() prototypes
that contain no const type modifier.  Yet the warning still appears.

This is unfortunate, since autoconf generates config.h files with the following code (which are expected to be #included before any other files):

/* Define to empty if `const' does not conform to ANSI C. */
#define const

Autoconf relying on being able to define "const" to nothing appears to
generate these warnings.

I'm not sure whether autoconf or gcc is in the wrong on this point --
does anyone have any guidance as to who might be doing the wrong
thing?

Thanks for your time!

-- 
Best of luck,
Mark Schreiber

Attachment: pgp3QFQSjLM8Q.pgp
Description: PGP signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux