clang and configure checking for equivalent simple type

Nali Toja nalitoja at gmail.com
Thu Sep 29 06:01:09 UTC 2011


"Klaus T. Aehlig" <aehlig at linta.de> writes:

[...]
> #include <sys/types.h>
> #include <unistd.h>
> int
> main ()
> {
> off_t u; long v; &u==&v;
>   ;
>   return 0;
> }
>
> and check for compile errors. However, the above program is rejected
> by clang, as the value &u==&v is unused, which, of course, has nothing
> to do with the intended check whether off_t * and long * are compatible
> pointer.
>
> Adding
>
> CFLAGS+= -Wno-unused 
>
> solves this problem.

Alternatively, you can turn off only a specific -Werror, e.g.

  CFLAGS += -Wno-error=unused

it's ignored by gcc in base while gcc46 wants -Wno-error=unused-value

  $ gcc -Wunused -Werror -Wno-error=unused test.c
  cc1: warnings being treated as errors
  test.c: In function 'main':
  test.c:6: warning: statement with no effect
  Exit 1

  $ gcc46 -Wunused -Werror -Wno-error=unused-value test.c
  test.c: In function 'main':
  test.c:6:18: warning: statement with no effect [-Wunused-value]

  $ clang -Wunused -Werror -Wno-error=unused test.c
  test.c:6:20: warning: expression result unused [-Wunused-value]
  off_t u; long v; &u==&v;
                   ~~^ ~~
  1 warning generated.


More information about the freebsd-ports mailing list