NetBSD-Bugs archive

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

Re: lib/49696: circular includes in sys/



The following reply was made to PR lib/49696; it has been noted by GNATS.

From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: lib/49696: circular includes in sys/
Date: Thu, 26 Feb 2015 04:16:36 +0000

 On Thu, Feb 26, 2015 at 03:55:00AM +0000, dholland%eecs.harvard.edu@localhost wrote:
  > The following include cycle exists:
  > 
  > sys/types.h -> machine/endian.h -> sys/endian.h -> 
  >    machine/bswap.h -> sys/bswap.h -> sys/types.h
  > 
  > (as well as a shorter one that doesn't involve bswap.h)
  > 
  > It all works, at the moment, but it's ugly and fragile.
 
 Actually, it doesn't:
 
 macaran% cat t.c
 #include <machine/bswap.h>
 macaran% gcc -c t.c
 In file included from /usr/include/amd64/bswap.h:13:0,
                  from t.c:1:
 /usr/include/sys/bswap.h:20:10: error: conflicting types for 'bswap16'
  uint16_t bswap16(uint16_t) __RENAME(__bswap16) __constfunc;
           ^
 In file included from /usr/include/amd64/endian.h:3:0,
                  from /usr/include/sys/types.h:98,
                  from /usr/include/amd64/byte_swap.h:42,
                  from /usr/include/amd64/bswap.h:10,
                  from t.c:1:
 /usr/include/sys/endian.h:203:1: note: previous implicit declaration of 'bswap16' was here
  __GEN_ENDIAN_ENC(16, be)
  ^
 In file included from /usr/include/amd64/bswap.h:13:0,
                  from t.c:1:
 /usr/include/sys/bswap.h:21:10: error: conflicting types for 'bswap32'
  uint32_t bswap32(uint32_t) __RENAME(__bswap32) __constfunc;
           ^
 In file included from /usr/include/amd64/endian.h:3:0,
                  from /usr/include/sys/types.h:98,
                  from /usr/include/amd64/byte_swap.h:42,
                  from /usr/include/amd64/bswap.h:10,
                  from t.c:1:
 /usr/include/sys/endian.h:204:1: note: previous implicit declaration of 'bswap32' was here
  __GEN_ENDIAN_ENC(32, be)
  ^
 In file included from /usr/include/amd64/bswap.h:13:0,
                  from t.c:1:
 /usr/include/sys/bswap.h:23:10: error: conflicting types for 'bswap64'
  uint64_t bswap64(uint64_t) __constfunc;
           ^
 In file included from /usr/include/amd64/endian.h:3:0,
                  from /usr/include/sys/types.h:98,
                  from /usr/include/amd64/byte_swap.h:42,
                  from /usr/include/amd64/bswap.h:10,
                  from t.c:1:
 /usr/include/sys/endian.h:205:1: note: previous implicit declaration of 'bswap64' was here
  __GEN_ENDIAN_ENC(64, be)
  ^
 Exit 1
 macaran% 
 
 -- 
 David A. Holland
 dholland%netbsd.org@localhost
 


Home | Main Index | Thread Index | Old Index