Subject: pcre build error (and hacky patch)
To: None <tech-pkg@NetBSD.org>
From: Hubert Feyrer <feyrer@cs.stevens.edu>
List: tech-pkg
Date: 11/12/2005 06:53:58
I had pkgsrc/devel/pcre fail with a strange error on NetBSD 2.0.2/i386, it 
seems to pull in type_traits.h in twice in the following fragment from 
pcre_stringpiece.h:

 	#if 1
 	#define HAVE_TYPE_TRAITS
 	#include <type_traits.h>
 	#elif 1
 	#define HAVE_TYPE_TRAITS
 	#include <bits/type_traits.h>
 	#endif

While I have no idea why this would happen, the patch below fixes this.
Full buildlog appended below.

I did suspect wrapper lossage, but a simple test worked fine, so that's 
probably something else.

Any clues?
What to do with the patch - commit?


  - Hubert


$NetBSD$

--- pcre_stringpiece.h.in.orig	2005-09-12 04:45:39.000000000 -0400
+++ pcre_stringpiece.h.in
@@ -42,10 +42,7 @@
  #include <string>
  #include <iosfwd>    // for ostream forward-declaration

-#if @pcre_have_type_traits@
-#define HAVE_TYPE_TRAITS
-#include <type_traits.h>
-#elif @pcre_have_bits_type_traits@
+#if @pcre_have_bits_type_traits@
  #define HAVE_TYPE_TRAITS
  #include <bits/type_traits.h>
  #endif



  c++ -c -O2 -I. -DSUPPORT_UTF8 -DPOSIX_MALLOC_THRESHOLD=10 ./pcrecpp.cc  -fPIC -DPIC -o .libs/pcrecpp.o
In file included from pcre_stringpiece.h:47,
                  from pcrecpp.cc:45:
/usr/include/g++/type_traits.h:55: error: redefinition of `struct __true_type'
/usr/include/g++/bits/type_traits.h:90: error: previous definition of `struct
    __true_type'
/usr/include/g++/type_traits.h:58: error: redefinition of `struct __false_type'
/usr/include/g++/bits/type_traits.h:91: error: previous definition of `struct
    __false_type'
/usr/include/g++/type_traits.h:62: error: redefinition of `struct
    __type_traits<_Tp>'
/usr/include/g++/bits/type_traits.h:94: error: previous definition of `struct
    __type_traits<_Tp>'
/usr/include/g++/type_traits.h:96: error: redefinition of `struct
    __type_traits<bool>'
/usr/include/g++/bits/type_traits.h:123: error: previous definition of `struct
    __type_traits<bool>'
/usr/include/g++/type_traits.h:106: error: redefinition of `struct
    __type_traits<char>'
/usr/include/g++/bits/type_traits.h:131: error: previous definition of `struct
    __type_traits<char>'
/usr/include/g++/type_traits.h:114: error: redefinition of `struct
    __type_traits<signed char>'
/usr/include/g++/bits/type_traits.h:139: error: previous definition of `struct
    __type_traits<signed char>'
/usr/include/g++/type_traits.h:122: error: redefinition of `struct
    __type_traits<unsigned char>'
/usr/include/g++/bits/type_traits.h:147: error: previous definition of `struct
    __type_traits<unsigned char>'
/usr/include/g++/type_traits.h:132: error: redefinition of `struct
    __type_traits<wchar_t>'
/usr/include/g++/bits/type_traits.h:155: error: previous definition of `struct
    __type_traits<wchar_t>'
/usr/include/g++/type_traits.h:142: error: redefinition of `struct
    __type_traits<short int>'
/usr/include/g++/bits/type_traits.h:163: error: previous definition of `struct
    __type_traits<short int>'
/usr/include/g++/type_traits.h:150: error: redefinition of `struct
    __type_traits<short unsigned int>'
/usr/include/g++/bits/type_traits.h:171: error: previous definition of `struct
    __type_traits<short unsigned int>'
/usr/include/g++/type_traits.h:158: error: redefinition of `struct
    __type_traits<int>'
/usr/include/g++/bits/type_traits.h:179: error: previous definition of `struct
    __type_traits<int>'
/usr/include/g++/type_traits.h:166: error: redefinition of `struct
    __type_traits<unsigned int>'
/usr/include/g++/bits/type_traits.h:187: error: previous definition of `struct
    __type_traits<unsigned int>'
/usr/include/g++/type_traits.h:174: error: redefinition of `struct
    __type_traits<long int>'
/usr/include/g++/bits/type_traits.h:195: error: previous definition of `struct
    __type_traits<long int>'
/usr/include/g++/type_traits.h:182: error: redefinition of `struct
    __type_traits<long unsigned int>'
/usr/include/g++/bits/type_traits.h:203: error: previous definition of `struct
    __type_traits<long unsigned int>'
/usr/include/g++/type_traits.h:192: error: redefinition of `struct
    __type_traits<long long int>'
/usr/include/g++/bits/type_traits.h:211: error: previous definition of `struct
    __type_traits<long long int>'
/usr/include/g++/type_traits.h:200: error: redefinition of `struct
    __type_traits<long long unsigned int>'
/usr/include/g++/bits/type_traits.h:219: error: previous definition of `struct
    __type_traits<long long unsigned int>'
/usr/include/g++/type_traits.h:210: error: redefinition of `struct
    __type_traits<float>'
/usr/include/g++/bits/type_traits.h:227: error: previous definition of `struct
    __type_traits<float>'
/usr/include/g++/type_traits.h:218: error: redefinition of `struct
    __type_traits<double>'
/usr/include/g++/bits/type_traits.h:235: error: previous definition of `struct
    __type_traits<double>'
/usr/include/g++/type_traits.h:226: error: redefinition of `struct
    __type_traits<long double>'
/usr/include/g++/bits/type_traits.h:243: error: previous definition of `struct
    __type_traits<long double>'
/usr/include/g++/type_traits.h:237: error: redefinition of `struct
    __type_traits<_Tp*>'
/usr/include/g++/bits/type_traits.h:252: error: previous definition of `struct
    __type_traits<_Tp*>'
/usr/include/g++/type_traits.h:301: error: redefinition of `struct
    _Is_integer<_Tp>'
/usr/include/g++/bits/type_traits.h:264: error: previous definition of `struct
    _Is_integer<_Tp>'
/usr/include/g++/type_traits.h:307: error: redefinition of `struct
    _Is_integer<bool>'
/usr/include/g++/bits/type_traits.h:268: error: previous definition of `struct
    _Is_integer<bool>'
/usr/include/g++/type_traits.h:313: error: redefinition of `struct
    _Is_integer<char>'
/usr/include/g++/bits/type_traits.h:272: error: previous definition of `struct
    _Is_integer<char>'
/usr/include/g++/type_traits.h:317: error: redefinition of `struct
    _Is_integer<signed char>'
/usr/include/g++/bits/type_traits.h:276: error: previous definition of `struct
    _Is_integer<signed char>'
/usr/include/g++/type_traits.h:321: error: redefinition of `struct
    _Is_integer<unsigned char>'
/usr/include/g++/bits/type_traits.h:280: error: previous definition of `struct
    _Is_integer<unsigned char>'
/usr/include/g++/type_traits.h:327: error: redefinition of `struct
    _Is_integer<wchar_t>'
/usr/include/g++/bits/type_traits.h:284: error: previous definition of `struct
    _Is_integer<wchar_t>'
/usr/include/g++/type_traits.h:333: error: redefinition of `struct
    _Is_integer<short int>'
/usr/include/g++/bits/type_traits.h:288: error: previous definition of `struct
    _Is_integer<short int>'
/usr/include/g++/type_traits.h:337: error: redefinition of `struct
    _Is_integer<short unsigned int>'
/usr/include/g++/bits/type_traits.h:292: error: previous definition of `struct
    _Is_integer<short unsigned int>'
/usr/include/g++/type_traits.h:341: error: redefinition of `struct
    _Is_integer<int>'
/usr/include/g++/bits/type_traits.h:296: error: previous definition of `struct
    _Is_integer<int>'
/usr/include/g++/type_traits.h:345: error: redefinition of `struct
    _Is_integer<unsigned int>'
/usr/include/g++/bits/type_traits.h:300: error: previous definition of `struct
    _Is_integer<unsigned int>'
/usr/include/g++/type_traits.h:349: error: redefinition of `struct
    _Is_integer<long int>'
/usr/include/g++/bits/type_traits.h:304: error: previous definition of `struct
    _Is_integer<long int>'
/usr/include/g++/type_traits.h:353: error: redefinition of `struct
    _Is_integer<long unsigned int>'
/usr/include/g++/bits/type_traits.h:308: error: previous definition of `struct
    _Is_integer<long unsigned int>'
/usr/include/g++/type_traits.h:359: error: redefinition of `struct
    _Is_integer<long long int>'
/usr/include/g++/bits/type_traits.h:312: error: previous definition of `struct
    _Is_integer<long long int>'
/usr/include/g++/type_traits.h:363: error: redefinition of `struct
    _Is_integer<long long unsigned int>'
/usr/include/g++/bits/type_traits.h:316: error: previous definition of `struct
    _Is_integer<long long unsigned int>'
In file included from pcrecpp.cc:45:
pcre_stringpiece.h: In constructor `pcrecpp::StringPiece::StringPiece()':
pcre_stringpiece.h:67: error: `NULL' undeclared (first use this function)
pcre_stringpiece.h:67: error: (Each undeclared identifier is reported only once
    for each function it appears in.)
*** Error code 1

Stop.
make: stopped in /var/tmp/hubertf/pkgsrc/devel/pcre/work.i386/pcre-6.4