dnl Disable any caching here define([AC_CACHE_LOAD], )dnl define([AC_CACHE_SAVE], )dnl dnl Process this file with autoconf to produce a configure script. AC_INIT(stlconf.h.in) AC_CONFIG_HEADER(stlconf.h) AC_MSG_RESULT(*** $0: STLport configuration utility ***) if test "${CXXFLAGS}" = ""; then AC_MSG_RESULT(* Note: for best reliability - try \"CXXFLAGS=-treat_warnings_as_errors\" $0 ) AC_MSG_RESULT(* Please don't forget specifying typical CXXFLAGS you'll be using - ) AC_MSG_RESULT(* such as that enabling exceptions handling, etc. ) dnl AC_MSG_RESULT(* Add option forcing instantiation of all templates to CXXFLAGS if possible. ) fi AC_MSG_RESULT(Please stand by while exploring compiler capabilities...) AC_MSG_RESULT(Be patient - that may take a while...) AC_MSG_RESULT(***) # utility function check_warning () { warn_str=`tail -1 config.log | egrep -i "arning|\(W\)"` if test "$warn_str" = ""; then return 0 else return 1 fi } dnl Checks for systems dnl AC_AIX dnl Checks for programs. dnl sets CXX AC_ARG_ENABLE(extension,[--enable-extension=], [ case "$enableval" in no) AC_MSG_RESULT(Info :.cpp used as extension for tests) ac_ext=cpp ;; *) AC_MSG_RESULT(Argument : .$enableval used as extension) ac_ext=$enableval esac ], [AC_MSG_RESULT(Info : .cpp used as extension for tests) ac_ext=cpp ] ) # Save that, as it is being redefined several times use_ac_ext=$ac_ext AC_PROG_CXX ac_ext=$use_ac_ext AC_LANG_CPLUSPLUS ac_ext=$use_ac_ext AC_CHECK_SIZEOF(int,4) ac_ext=$use_ac_ext if test "$ac_cv_sizeof_int" = "4"; then AC_DEFINE_UNQUOTED(_STLP_UINT32_T,unsigned int) else AC_CHECK_SIZEOF(long,4) ac_ext=$use_ac_ext if test "$ac_cv_sizeof_long" = "4"; then AC_DEFINE_UNQUOTED(_STLP_UINT32_T,unsigned long) else dnl ELBRUS ??? ;) AC_CHECK_SIZEOF(short,4) if test "$ac_cv_sizeof_short" = "4"; then AC_DEFINE_UNQUOTED(_STLP_UINT32_T,unsigned short) else AC_MSG_ERROR(Cannot find any 32-bit integer type for your compiler) fi ac_ext=$use_ac_ext fi fi ac_ext=$use_ac_ext dnl Exclude link stage for cross-compilation if test "$ac_cv_c_cross" = "yes"; then CXXFLAGS="${CXXFLAGS} -c" fi ac_ext=$use_ac_ext dnl checking for compiler capabilities AC_MSG_CHECKING(for basic STL compatibility) AC_TRY_LINK( [ template struct binary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Result result_type; }; template struct plus : public binary_function { T operator()(const T& x, const T& y) const; }; template T plus::operator()(const T& x, const T& y) const { return x + y; } plus p; ], [], [ac_cv_compat="yes"], [AC_MSG_ERROR(Your compiler won't be able to compile this implementation. Sorry.) ac_cv_compat="no"] ) AC_MSG_RESULT($ac_cv_compat) AC_MSG_CHECKING(for partial specialization syntax) AC_TRY_LINK( [ template class fs_foo {}; template <> class fs_foo {};], [ fs_foo i;], [ _FULL_SPEC="template <>" ac_cv_spec_syntax="yes"], [ AC_DEFINE(_STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX) ac_cv_spec_syntax="no" _FULL_SPEC=""]) AC_MSG_RESULT($ac_cv_spec_syntax) AC_MSG_CHECKING(for bool keyword) AC_TRY_COMPILE( [bool b_foo() { return true; }], [(void)b_foo();], [ac_cv_bool="yes"], [AC_DEFINE(_STLP_NO_BOOL) ac_cv_bool="no"]) AC_MSG_RESULT($ac_cv_bool) if test "$ac_cv_bool" = "no"; then AC_MSG_CHECKING(for yvals.h header) AC_TRY_COMPILE([#include extern bool aaa=true; ], [], [AC_DEFINE(_STLP_YVALS_H) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) AC_MSG_CHECKING(whether bool is reserved word) AC_TRY_COMPILE( [typedef int bool;], [], [ac_cv_bool_reserved="no"], [AC_DEFINE(_STLP_DONT_USE_BOOL_TYPEDEF) ac_cv_bool_reserved="yes"]) AC_MSG_RESULT($ac_cv_bool_reserved) ]) fi AC_MSG_CHECKING(for wchar_t type) AC_TRY_COMPILE( [ #include wchar_t wc_foo() { return 'a'; }], [(void)wc_foo();], [ac_cv_wchar="yes"], [AC_DEFINE(_STLP_NO_WCHAR_T) ac_cv_wchar="no"]) AC_MSG_RESULT($ac_cv_wchar) AC_MSG_CHECKING(if wchar_t is unsigned short) AC_TRY_COMPILE( [ # include template struct foo {}; $_FULL_SPEC struct foo {}; typedef unsigned short u__short; $_FULL_SPEC struct foo {}; foo f1; foo f2; ], [], [ac_cv_wchar_short="no"], [AC_DEFINE(_STLP_WCHAR_T_IS_USHORT) ac_cv_wchar_short="yes"]) AC_MSG_RESULT($ac_cv_wchar_short) AC_MSG_CHECKING(for long long type) AC_TRY_COMPILE( [long long ll_foo() { return 0; }], [(void)ll_foo();], [AC_DEFINE(_STLP_LONG_LONG) ac_cv_long_long="yes"], [ac_cv_long_long="no"]) AC_MSG_RESULT($ac_cv_long_long) AC_MSG_CHECKING(for long double type) AC_TRY_COMPILE( [long double ld_foo() { return 0; }], [(void)ld_foo();], [ac_cv_long_double="yes"], [AC_DEFINE(_STLP_NO_LONG_DOUBLE) ac_cv_long_double="no"]) AC_MSG_RESULT($ac_cv_long_double) AC_MSG_CHECKING(for typename keyword) AC_TRY_LINK( [ template struct pair { typedef T1 first_type; typedef T2 second_type; }; template struct unary_function { typedef Arg argument_type; typedef Result result_type; }; template struct select2nd : public unary_function { typedef typename Pair::first_type ignored_type; const typename Pair::second_type& operator()(const typename Pair::second_type& x, const ignored_type& ) const { return x; } }; ], [ typedef pair tn_p; select2nd< tn_p > tn_s; (void)tn_s(1,5); ], [__TYPENAME="typename" ac_cv_typename="yes"], [__TYPENAME="" AC_DEFINE(_STLP_NEED_TYPENAME) ac_cv_typename="no"]) AC_MSG_RESULT($ac_cv_typename) AC_MSG_CHECKING(for explicit keyword) AC_TRY_COMPILE( [struct expl_Class { int a; explicit expl_Class(int t): a(t) {} }; expl_Class c(1); ], [], [ac_cv_explicit="yes"], [AC_DEFINE(_STLP_NO_EXPLICIT) ac_cv_explicit="no"]) AC_MSG_RESULT($ac_cv_explicit) AC_MSG_CHECKING(for mutable keyword) AC_TRY_COMPILE( [struct mut_Class { mutable int a; void update() const { a=0; } }; mut_Class c; ], [c.update()], [ac_cv_mutable="yes"], [AC_DEFINE(_STLP_NEED_MUTABLE) ac_cv_mutable="no"]) AC_MSG_RESULT($ac_cv_mutable) AC_MSG_CHECKING(for new style casts) AC_TRY_COMPILE( [struct ncast_Class { int a; void update(int* i) { *i=a; } }; ncast_Class c; ], [ const int a(5); c.update(const_cast(&a)) ], [ac_cv_new_cast="yes"], [AC_DEFINE(_STLP_NO_NEW_STYLE_CASTS) ac_cv_new_cast="no"]) AC_MSG_RESULT($ac_cv_new_cast) AC_MSG_CHECKING(for new-style C library headers) AC_TRY_COMPILE( [ #include #include #include #include #include #include #include #ifndef _STLP_NO_WCHAR_T #include #endif ], [], [ac_cv_newheaders="yes"], [AC_DEFINE(_STLP_HAS_NO_NEW_C_HEADERS) ac_cv_newheaders="no"]) AC_MSG_RESULT($ac_cv_newheaders) AC_MSG_CHECKING(for new-style header) AC_TRY_COMPILE( [ #include ], [], [ac_cv_new_new="yes"], [AC_DEFINE(_STLP_NO_NEW_NEW_HEADER) ac_cv_new_new="no"]) AC_MSG_RESULT($ac_cv_new_new) AC_MSG_CHECKING(for member template methods) AC_TRY_LINK( [ template struct mt_foo { typedef Result result_type; template result_type operate(const Arg&) { return Result(); } }; mt_foo p; ], [ (void)p.operate((char*)"aaa"); ], [ac_cv_member_templates="yes"], [AC_DEFINE(_STLP_NO_MEMBER_TEMPLATES) ac_cv_member_templates="no"] ) AC_MSG_RESULT($ac_cv_member_templates) AC_MSG_CHECKING(for friend templates) AC_TRY_LINK( [ template class foo; template struct ft_foo { typedef Result result_type; template friend class foo; }; ft_foo p; ], [], [ac_cv_friend_templates="yes"], [AC_DEFINE(_STLP_NO_FRIEND_TEMPLATES) ac_cv_friend_templates="no"] ) AC_MSG_RESULT($ac_cv_friend_templates) AC_MSG_CHECKING(for qualified friend templates) AC_TRY_LINK( [ ${_TEST_STD_BEGIN} template class foo; template struct ft_foo { typedef Result result_type; template friend class $_TEST_STD::foo; }; ft_foo p; ${_TEST_STD_END} ], [], [ac_cv_qual_friend_templates="yes"], [AC_DEFINE(_STLP_NO_QUALIFIED_FRIENDS) ac_cv_qual_friend_templates="no"] ) AC_MSG_RESULT($ac_cv_qual_friend_templates) AC_MSG_CHECKING(for member template keyword) AC_TRY_LINK( [ template struct nt_foo { typedef Result result_type; template struct rebind { typedef nt_foo other; }; }; template struct _Traits { typedef typename _Allocator:: template rebind<_Tp> my_rebind; typedef typename my_rebind::other allocator_type; }; nt_foo p; _Traits< int, nt_foo > pp; ], [], [ac_cv_member_template_keyword="yes"], [AC_DEFINE(_STLP_NO_MEMBER_TEMPLATE_KEYWORD) ac_cv_member_template_keyword="no"] ) AC_MSG_RESULT($ac_cv_member_template_keyword) if test "$ac_cv_member_template_keyword" = "no"; then AC_MSG_CHECKING(for member template classes) AC_TRY_LINK( [ template struct nt_foo { typedef Result result_type; template struct rebind { typedef nt_foo other; }; }; template struct _Traits { typedef typename _Allocator::rebind<_Tp> my_rebind; typedef typename my_rebind::other allocator_type; }; nt_foo p; _Traits< int, nt_foo > pp; ], [], [ac_cv_member_template_classes="yes"], [AC_DEFINE(_STLP_NO_MEMBER_TEMPLATE_CLASSES) ac_cv_member_template_classes="no"] ) AC_MSG_RESULT($ac_cv_member_template_classes) fi AC_MSG_CHECKING(for partial class specialization) AC_TRY_LINK( [ template struct ps_foo { typedef Arg argument_type; typedef Result result_type; }; template struct ps_foo { void bar() {} }; template struct ps_foo { void foo() {} }; ps_foo p; ps_foo p1; ], [p.bar(); p1.foo();], [ac_cv_partial_spec="yes"], [AC_DEFINE(_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) ac_cv_partial_spec="no"] ) AC_MSG_RESULT($ac_cv_partial_spec) if test "$ac_cv_partial_spec" = yes; then AC_MSG_CHECKING(if explicit args accepted on constructors of partial specialized classes) AC_TRY_LINK( [ template struct ps_foo { typedef Arg argument_type; typedef Result result_type; }; template struct ps_foo { ps_foo() {} void bar() {} }; template struct ps_foo { ps_foo() {} void bar() {} }; ps_foo p; ps_foo p1; ], [p.bar(); p1.foo();], [AC_DEFINE(_STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS) ac_cv_partial_spec_needs_args="yes"], [ac_cv_partial_spec_needs_args="no"] ) AC_MSG_RESULT($ac_cv_partial_spec_needs_args) fi if test ac_cv_partial_spec_needs_args=="no"; then AC_MSG_CHECKING(if explicit args accepted on constructors of explicitly specialized classes) AC_TRY_LINK( [ template struct ps_foo { typedef Arg argument_type; typedef Result result_type; void bar() {} }; template struct ps_foo { ps_foo() {} void foo() {} }; ps_foo p; ps_foo p1; ], [p.bar(); p1.foo();], [AC_DEFINE(_STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS) ac_cv_partial_spec_needs_args="yes"], [ac_cv_partial_spec_needs_args="no"] ) AC_MSG_RESULT($ac_cv_partial_spec_needs_args) fi AC_MSG_CHECKING(for partial template function ordering) AC_TRY_LINK( [ template Result po_foo (const Arg& a,const Result&){ return (Result)a.nothing; } template struct A { T a; A(int _a) : a(_a) {} }; template T po_foo (const A& a, const A& b){ return a.a; } ], [ A po_a(0); A po_b(1); (void)po_foo(po_b, po_a) ], [ac_cv_partial_ord="yes"], [AC_DEFINE(_STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER) ac_cv_partial_ord="no"] ) AC_MSG_RESULT($ac_cv_partial_ord) AC_MSG_CHECKING(for method specialization) AC_TRY_LINK( [ template struct ms_foo { typedef Arg argument_type; typedef Result result_type; inline void bar(); }; template inline void ms_foo::bar() {} inline void ms_foo::bar() {} ms_foo p; ms_foo p1; ], [p.bar(); p1.bar();], [ac_cv_method_spec="yes"], [AC_DEFINE(_STLP_NO_METHOD_SPECIALIZATION) ac_cv_method_spec="no"] ) AC_MSG_RESULT($ac_cv_method_spec) AC_MSG_CHECKING(for lrand48 function) AC_TRY_LINK( [#include ], [long i = lrand48();], [AC_DEFINE(_STLP_RAND48) ac_cv_func_lrand48="yes"], [ac_cv_func_lrand48="no"]) AC_MSG_RESULT($ac_cv_func_lrand48) AC_MSG_CHECKING(for default template parameters) AC_TRY_LINK( [template struct less {}; template > struct Class { T1 t1; }; Class cl; Class > cl2; ], [], [ac_cv_default_template_param="yes"], [AC_DEFINE(_STLP_LIMITED_DEFAULT_TEMPLATES) ac_cv_default_template_param="no"]) AC_MSG_RESULT($ac_cv_default_template_param) if test "$ac_cv_default_template_param" = "no"; then AC_MSG_CHECKING(for default type parameters) AC_TRY_LINK( [ template struct less { typedef int int_t; }; template > struct Class { private: int a; public: typedef Class self; typedef $__TYPENAME T1::int_t int_t; self foo (const Class& t) { if ( t.a==a ) return *this; else return t; } }; Class cl; Class > cl2; ], [], [AC_DEFINE(_STLP_DEFAULT_TYPE_PARAM) ac_cv_default_type_param="yes"], [ac_cv_default_type_param="no"]) AC_MSG_RESULT($ac_cv_default_type_param) fi dnl let's check if non-type cannot be default AC_MSG_CHECKING(for default non-type parameters) AC_TRY_LINK( [ template struct Class { private: T* t; enum { t1=N }; public: int get_n() { return N; } }; Class cl; Class cl2; ], [], [ac_cv_default_nontype_param="yes"], [AC_DEFINE(_STLP_NO_DEFAULT_NON_TYPE_PARAM) ac_cv_default_nontype_param="no"] ) AC_MSG_RESULT($ac_cv_default_nontype_param) AC_MSG_CHECKING(for non-type parameter bug) AC_TRY_LINK( [ template struct Class { private: T* t; enum { t1=N }; public: int get_n() { return N; } }; template int operator==(const Class& , const Class& ) { return 0; } Class cl; Class cl2; int i(cl==cl2); ], [], [ac_cv_nontype_param_bug="no"], [AC_DEFINE(_STLP_NON_TYPE_TMPL_PARAM_BUG) ac_cv_nontype_param_bug="yes"] ) AC_MSG_RESULT($ac_cv_nontype_param_bug) AC_MSG_CHECKING(for static data member templates) AC_TRY_LINK( [template struct Class { static int a; }; template int Class::a;], [], [ac_cv_static_templates="yes"], [AC_DEFINE(_STLP_NO_STATIC_TEMPLATE_DATA) ac_cv_static_templates="no"]) AC_MSG_RESULT($ac_cv_static_templates) if test "$ac_cv_static_templates" = no; then AC_MSG_CHECKING(for weak attribute) AC_TRY_COMPILE( [int a_w __attribute__((weak));], [], [AC_DEFINE(_STLP_WEAK_ATTRIBUTE) ac_cv_weak_attribute="yes"], [ac_cv_weak_attribute="no"]) AC_MSG_RESULT($ac_cv_weak_attribute) fi if test "$ac_cv_static_templates" = yes; then AC_MSG_CHECKING(for static array member size bug) AC_TRY_LINK( [template struct Class { enum { sz=5 }; static int a[sz]; }; template int Class::a[Class::sz];], [], [ac_cv_static_array_bug="no"], [AC_DEFINE(_STLP_STATIC_ARRAY_BUG) ac_cv_static_array_bug="yes"]) AC_MSG_RESULT($ac_cv_static_array_bug) fi AC_MSG_CHECKING(for static data member const initializer bug) AC_TRY_LINK( [template struct Class { static const int a = 1; }; template const int Class::a;], [], [ac_cv_static_init_bug="no"], [AC_DEFINE(_STLP_STATIC_CONST_INIT_BUG) ac_cv_static_init_bug="yes"]) AC_MSG_RESULT($ac_cv_static_init_bug) AC_MSG_CHECKING(for namespaces support) AC_TRY_COMPILE( [class test_class {}; namespace std { using ::test_class; template struct Class { typedef T my_type; }; typedef Class::my_type int_type; }; inline int ns_foo (std::int_type t) { using namespace std; int_type i =2; return i+t; } ], [(void)ns_foo(1);], [_TEST_STD="std" _TEST_STD_BEGIN="namespace $_TEST_STD" _TEST_STD_END="namespace $_TEST_STD" ac_cv_namespaces="yes"], [AC_DEFINE(_STLP_HAS_NO_NAMESPACES) _TEST_STD="" _TEST_STD_BEGIN="" _TEST_STD_END="" ac_cv_namespaces="no"]) AC_MSG_RESULT($ac_cv_namespaces) AC_MSG_CHECKING(for broken "using" directive) AC_TRY_COMPILE( [namespace std { template struct Class { typedef T my_type; }; typedef Class::my_type int_type; template void foo(T,int) {} template void foo(T,int,int) {} }; using std::Class; using std::foo; ], [(void)foo(1,1);], [ac_cv_broken_using="no"], [ac_cv_broken_using="yes"]) if test "$ac_cv_broken_using" = no; then # check if no warnings have been issued if `check_warning` ; then ac_cv_broken_using=no else AC_DEFINE(_STLP_BROKEN_USING_DIRECTIVE) fi else AC_DEFINE(_STLP_BROKEN_USING_DIRECTIVE) fi AC_MSG_RESULT($ac_cv_broken_using) if test "$ac_cv_namespaces" = yes; then AC_ARG_ENABLE(namespaces,[--enable-namespaces Use namespaces (default if posssible) --disable-namespaces Don't use namespaces support], [ case "$enableval" in no) AC_DEFINE(_STLP_NO_NAMESPACES) _TEST_STD="" _TEST_STD_BEGIN="" _TEST_STD_END="" AC_MSG_RESULT(Config arg --disable-namespaces : code not put into namespace by user request);; *) AC_MSG_RESULT(Config default: code put into namespace) esac ], [AC_MSG_RESULT(Config default: code put into namespace)] ) else AC_MSG_RESULT(Compiler restriction : no namespaces support used) fi AC_MSG_CHECKING(for exceptions support) AC_TRY_COMPILE( [int ex_foo() { try { try { throw(1); } catch (int a) { throw; } } catch (...) {;} return 0; }], [(void)ex_foo();], [ac_cv_exceptions="yes"], [AC_DEFINE(_STLP_HAS_NO_EXCEPTIONS) ac_cv_exceptions="no"]) AC_MSG_RESULT($ac_cv_exceptions) if test "$ac_cv_exceptions" = yes; then AC_MSG_CHECKING(if exceptions specification works) AC_TRY_COMPILE( [template inline int ex_spec_foo(const T&) throw () { return 0;} ], [(void)ex_spec_foo(5);], [ac_cv_exception_spec="yes"], [AC_DEFINE(_STLP_NO_EXCEPTION_SPEC) ac_cv_exception_spec="no"]) dnl if test "$ac_cv_exception_spec" = yes; then dnl # check if no warnings have been issued dnl if `check_warning` ; then dnl AC_DEFINE(_STLP_EXCEPTION_SPEC) dnl else dnl ac_cv_exception_spec=no dnl fi dnl fi AC_MSG_RESULT($ac_cv_exception_spec) AC_MSG_CHECKING(if return is required after throw) AC_TRY_COMPILE( [int ex_foo() { try { try { throw(1); } catch (int a) { throw; } } catch (...) {;} return 0; }], [(void)ex_foo();], [ac_cv_throw_return_bug="no"], [AC_DEFINE(_STLP_THROW_RETURN_BUG) ac_cv_throw_return_bug="yes"]) if test "$ac_cv_throw_return_bug" = no; then # check if no warnings have been issued if `check_warning` ; then ac_cv_throw_return_bug="no" else AC_DEFINE(_STLP_THROW_RETURN_BUG) ac_cv_throw_return_bug="yes" fi fi AC_MSG_RESULT($ac_cv_throw_return_bug) fi AC_MSG_CHECKING(for native header with basic_string defined ) AC_TRY_COMPILE( [ #include # if !defined (_STLP_HAS_NO_NAMESPACES) using namespace $_TEST_STD; # endif basic_string, allocator > bs; string bd = bs; ], [], [ ac_cv_string_header="yes"], [ AC_DEFINE(_STLP_NO_STRING_HEADER) ac_cv_string_header="no"] ) AC_MSG_RESULT($ac_cv_string_header) dnl there could be no correct stdexcept/iostream without string if test "$ac_cv_string_header" = yes; then AC_MSG_CHECKING(for native header) AC_TRY_COMPILE( [ #include # if !defined (_STLP_HAS_NO_NAMESPACES) using namespace $_TEST_STD; # endif string s; logic_error le(s); runtime_error re(s); domain_error de(s); invalid_argument ia(s); length_error lne(s); out_of_range or(s); range_error rne(s); overflow_error ove(s); underflow_error ue(s); ], [], [ac_cv_stdexcept_header="yes"], [AC_DEFINE(_STLP_NO_STDEXCEPT_HEADER) ac_cv_stdexcept_header="no"] ) AC_MSG_RESULT($ac_cv_stdexcept_header) AC_MSG_CHECKING(for new iostreams) AC_TRY_COMPILE( [ #include #include # if !defined (_STLP_HAS_NO_NAMESPACES) using namespace $_TEST_STD; # endif template void outp(basic_ostream<_Tp,_Traits>& o, char* str) { o< header with class "exception" defined) AC_TRY_COMPILE( [ #include # if !defined (_STLP_HAS_NO_NAMESPACES) using namespace $_TEST_STD; # endif class my_exception: public $_TEST_STD::exception {}; my_exception mm; ], [], [ac_cv_exception_header="yes"], [AC_DEFINE(_STLP_NO_EXCEPTION_HEADER) ac_cv_exception_header="no"] ) AC_MSG_RESULT($ac_cv_exception_header) AC_MSG_CHECKING(builtin constructor bug) AC_TRY_RUN( [ # ifdef _STLP_USE_NEW_STYLE_HEADERS # include # include # include # include # else # include # include # include # include # endif int main(int, char**) { int i; double buf[1000]; char* pc = (char*)buf; short* ps = (short*)buf; int* pi = (int*)buf; long* pl = (long*)buf; double* pd = (double*)buf; float* pf = (float*)buf; for (i=0; i<100; i++) { new(pc) char(); assert(char()==0 && *pc==0); sprintf(pc,"lalala\n"); new (ps) short(); assert(short()==0 && *ps ==0); sprintf(pc,"lalala\n"); new (pi) int(); assert(int()==0 && *pi == 0); sprintf(pc,"lalala\n"); new (pl) long(); assert(long()==0 && *pl == 0); sprintf(pc,"lalala\n"); new (pf) float(); assert(float()==0.0 && *pf == 0.0); sprintf(pc,"lalala\n"); new (pd) double(); assert(double()==0.0 && *pd == 0.0); sprintf(pc,"lalala\n"); } return 0; } ], [ ac_cv_builtin_c_bug="no"], [ AC_DEFINE(_STLP_DEFAULT_CONSTRUCTOR_BUG) ac_cv_builtin_c_bug="yes"], [ AC_DEFINE(_STLP_DEFAULT_CONSTRUCTOR_BUG) ac_cv_builtin_c_bug="yes"] ) AC_MSG_RESULT($ac_cv_builtin_c_bug) AC_MSG_CHECKING(for trivial constructor bug) AC_TRY_LINK( [struct output_iterator_tag {}; void tc_bug_foo(output_iterator_tag) {} inline void tc_test_foo() { tc_bug_foo(output_iterator_tag()); }], [tc_test_foo();], [ac_cv_tc_bug="no"], [AC_DEFINE(_STLP_TRIVIAL_CONSTRUCTOR_BUG) ac_cv_tc_bug="yes"]) AC_MSG_RESULT($ac_cv_tc_bug) AC_MSG_CHECKING(for trivial destructor bug) AC_TRY_LINK( [struct output_iterator_tag {output_iterator_tag() {} }; output_iterator_tag* td_bug_bar ; ], [ td_bug_bar->~output_iterator_tag(); ], [ac_cv_td_bug="no"], [AC_DEFINE(_STLP_TRIVIAL_DESTRUCTOR_BUG) ac_cv_td_bug="yes"]) AC_MSG_RESULT($ac_cv_td_bug) AC_MSG_CHECKING(for explicit function template arguments) AC_TRY_LINK( [ template class foo; template bool operator==(const foo& lhs,const foo& rhs); template class foo { private: T bar; friend bool operator== <> (const foo&,const foo&); }; template bool operator==(const foo& lhs,const foo& rhs) { return lhs.bar==rhs.bar; }], [ foo f1, f2; int ret= (f1==f2) ], [ _NULLARGS="<>" ac_cv_expl_fun_args="yes"], [ AC_DEFINE(_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) ac_cv_expl_fun_args="no" _NULLARGS=""]) AC_MSG_RESULT($ac_cv_expl_fun_args) AC_MSG_CHECKING(for template parameter baseclass matching) AC_TRY_LINK( [struct output_iterator_tag {}; struct derived1_tag : public output_iterator_tag {}; struct derived2_tag : public derived1_tag {}; template struct output_iterator { public: output_iterator() {} ~output_iterator() {} friend inline int operator== $_NULLARGS (const output_iterator&, const output_iterator&); }; template inline int operator==(const output_iterator&, const output_iterator&) { return 0; } template inline output_iterator_tag iterator_category(const output_iterator&) {return output_iterator_tag();} template struct derived_iterator : public output_iterator { public: derived_iterator() {} ~derived_iterator() {} }; template inline T select_foo(T t, output_iterator_tag) { return t;} template inline int select_foo_2(T, T, output_iterator_tag) { return 0;} template inline T tbase_foo(T pm ) { derived_iterator di1, di2; int i( di1==di2 && pm); return select_foo((int)1,iterator_category(derived_iterator())); } ], [ (void)tbase_foo((int)1); ], [ac_cv_base_match="yes"], [AC_DEFINE(_STLP_BASE_MATCH_BUG) ac_cv_base_match="no"]) AC_MSG_RESULT($ac_cv_base_match) AC_MSG_CHECKING(for non-template parameter baseclass matching ) AC_TRY_LINK( [struct output_iterator_tag {}; struct derived1_tag : public output_iterator_tag {}; struct derived2_tag : public derived1_tag {}; struct derived3_tag : public derived2_tag {}; template struct output_iterator { public: output_iterator() {} ~output_iterator() {} }; template inline output_iterator_tag iterator_category(const output_iterator&) {return output_iterator_tag();} template struct derived_iterator : public output_iterator { public: derived_iterator() {} ~derived_iterator() {} }; template inline int select_foo_2(T, T, output_iterator_tag) { return 0;} template inline int select_foo_2(T, T, derived1_tag) { return 0;} template inline void nont_base_foo(T pm ) { derived_iterator di1, di2; (void)select_foo_2(di1, (const derived_iterator&)di2, derived3_tag()); } ], [ nont_base_foo((int)1); ], [ac_cv_nont_base_match="yes"], [AC_DEFINE(_STLP_NONTEMPL_BASE_MATCH_BUG) ac_cv_nont_base_match="no"]) AC_MSG_RESULT($ac_cv_nont_base_match) AC_MSG_CHECKING(for nested type parameters bug) AC_TRY_LINK( [template struct nt_o { typedef int ii; inline ii foo(ii);}; template inline nt_o::ii nt_o::foo(ii) { return 0; }], [], [ac_cv_nested_type_param_bug="no"], [AC_DEFINE(_STLP_NESTED_TYPE_PARAM_BUG) ac_cv_nested_type_param_bug="yes"]) AC_MSG_RESULT($ac_cv_nested_type_param_bug) AC_MSG_CHECKING(if inherited template typedefs broken completely) AC_TRY_LINK( [ template struct binary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Result result_type; }; template struct equal_to : public binary_function { int operator()(const T& x, const T& y) const { return x == y; } }; template class binary_negate : public binary_function<$__TYPENAME Predicate::first_argument_type, $__TYPENAME Predicate::second_argument_type, int> { protected: Predicate pred; public: binary_negate(const Predicate& x = Predicate()) : pred(x) {} int operator() (const $__TYPENAME Predicate::first_argument_type& x, const $__TYPENAME Predicate::second_argument_type& y) const { return !pred(x, y); } }; typedef equal_to eq_int; typedef binary_negate > int_negate; int_negate n; ], [ (void)n(1,2); ], [ac_cv_typebug="no"], [AC_DEFINE(_STLP_BASE_TYPEDEF_BUG) AC_DEFINE(_STLP_BASE_TYPEDEF_OUTSIDE_BUG) ac_cv_typebug="yes"]) AC_MSG_RESULT($ac_cv_typebug) AC_MSG_CHECKING(if inherited typedefs visible from outside) AC_TRY_COMPILE( [ template struct binary_function { typedef Arg1 first_argument_type; typedef Arg1 second_argument_type; typedef Result result_type; }; template class plus : public binary_function { public: plus() {} plus(const T&) {} T operator()(const T& x, const T& y) const { return x + y; }; }; plus p; plus::first_argument_type a; ], [], [ac_cv_outside_typedef="yes"], [AC_DEFINE(_STLP_BASE_TYPEDEF_OUTSIDE_BUG) ac_cv_outside_typedef="no"]) AC_MSG_RESULT($ac_cv_outside_typedef) # fi AC_MSG_CHECKING(if private type static members initializable) AC_TRY_COMPILE( [struct p_Class { private: struct str_ { int a; str_(int i) : a(i) {}}; static str_ my_int; }; p_Class::str_ p_Class::my_int(0); ], [], [ac_cv_private="yes"], [AC_DEFINE(_STLP_UNINITIALIZABLE_PRIVATE) ac_cv_private="no"]) AC_MSG_RESULT($ac_cv_private) AC_MSG_CHECKING(for const member constructor bug) AC_TRY_LINK([ template struct pair { T1 first; T2 second; pair(): first(T1()), second(T2()) {} pair(const pair& o) : first(o.first), second(o.second) {} }; pair< const int, const int > p; ], [], [ac_cv_const_constructor_bug="no"], [AC_DEFINE(_STLP_CONST_CONSTRUCTOR_BUG) ac_cv_const_constructor_bug="yes"]) AC_MSG_RESULT($ac_cv_const_constructor_bug) AC_MSG_CHECKING(for loop inline problems) AC_TRY_COMPILE( [inline int il_foo (int a) { int i; for (i=0; i0) a-=3; return a; }], [(void)il_foo(2);], [ac_cv_inline_problems="no"], [AC_DEFINE(_STLP_LOOP_INLINE_PROBLEMS) ac_cv_inline_problems="yes"]) if test "$ac_cv_inline_problems" = no; then # check if no warnings have been issued if `check_warning` ; then ac_cv_inline_problems="no" else AC_DEFINE(_STLP_LOOP_INLINE_PROBLEMS) ac_cv_inline_problems="yes" fi fi AC_MSG_RESULT($ac_cv_inline_problems) AC_MSG_CHECKING(if arrow operator always get instantiated) AC_TRY_LINK( [ template struct um_foo { T* ptr; T* operator ->() { return &(operator*());} T operator *() { return *ptr; } }; template int operator == ( const um_foo& x, const um_foo& y) { return *x == *y; } struct um_tag { int a ; }; um_foo f; um_foo a; ], [ int b(5); a.ptr=&b;], [ac_cv_unused_required="no"], [AC_DEFINE(_STPL_NO_ARROW_OPERATOR) ac_cv_unused_required="yes"] ) AC_MSG_RESULT($ac_cv_unused_required) AC_MSG_CHECKING(for pointer-to-member parameter bug) AC_TRY_COMPILE( [ struct pmf_foo { int bar() { return 0; }; }; template class mem_fun_t { protected: typedef Result (Class::*fun_type)(void); fun_type ptr; public: mem_fun_t() {} mem_fun_t(fun_type p) : ptr(p) {} Result operator()(Class* x) const { return (x->*ptr)();} }; template inline mem_fun_t mem_fun(Result (Class::*ptr)(void)) { return mem_fun_t(ptr); } ], [pmf_foo pmf; (void)mem_fun(&pmf_foo::bar)(&pmf)], [ac_cv_pmf_bug="no"], [AC_DEFINE( _STLP_MEMBER_POINTER_PARAM_BUG) ac_cv_pmf_bug="yes"]) AC_MSG_RESULT($ac_cv_pmf_bug) AC_MSG_CHECKING(if bad_alloc defined in ) AC_TRY_COMPILE( [ #if !defined (_STLP_NO_NEW_STYLE_HEADERS) #include #else #include #endif # if !defined (_STLP_HAS_NO_NAMESPACES) using namespace $_TEST_STD; # endif bad_alloc badalloc_foo() { bad_alloc err; return err;}], [(void)badalloc_foo()], [ac_cv_bad_alloc="yes"], [AC_DEFINE(_STLP_NO_BAD_ALLOC) ac_cv_bad_alloc="no"]) AC_MSG_RESULT($ac_cv_bad_alloc) AC_MSG_CHECKING(for __type_traits automatic specialization) AC_TRY_LINK( [template int tt_foo(const T&) { typedef __type_traits traits; return 0; }], [(void)tt_foo(5)], [AC_DEFINE(_STLP_AUTOMATIC_TYPE_TRAITS) ac_cv_type_traits="yes"], [ac_cv_type_traits="no"]) AC_MSG_RESULT($ac_cv_type_traits) # package options - exceptions AC_MSG_RESULT(***) AC_MSG_RESULT($0: Setting implementation options...) AC_MSG_RESULT(***) if test "$ac_cv_exceptions" = yes; then AC_ARG_ENABLE(exceptions,[--enable-exceptions Use exceptions support (default if posssible) --disable-exceptions Don't use exceptions support], [ case "$enableval" in no) AC_DEFINE(_STLP_NO_EXCEPTIONS) AC_MSG_RESULT(Config arg --disable-exceptions : disabling exceptions by user request);; *) AC_MSG_RESULT(Config default: exceptions enabled) esac ], [AC_MSG_RESULT(Config default: exceptions enabled) ] ) else AC_MSG_RESULT(Compiler restriction : no exceptions support used) fi if test "$ac_cv_namespaces" = yes; then AC_ARG_ENABLE(relops,[--enable-relops Separate rel_ops namespace for relational operators (default if posssible) --disable-relops No separate rel_ops namespace for relational operators], [ case "$enableval" in no) AC_DEFINE(_STLP_NO_RELOPS_NAMESPACE) AC_MSG_RESULT(Config arg --disable-relops : no std::rel_ops namespace by user request);; *) AC_MSG_RESULT(Config default: Separate std::rel_ops namespace for relational operators) esac ], [AC_MSG_RESULT(Config default: Separate std::rel_ops namespace for relational operators)] ) else AC_DEFINE(_STLP_NO_RELOPS_NAMESPACE) fi if test "$ac_cv_newheaders" = yes; then AC_ARG_ENABLE(new-style-headers,[--enable-new-style-headers Use new-style headers (default) --disable-new-style-headers Don't use new-style headers], [ case "$enableval" in no) AC_DEFINE(_STLP_NO_NEW_STYLE_HEADERS) AC_MSG_RESULT(Config arg --disable-new-style-headers : not using new-style headers);; *) AC_MSG_RESULT(Config default: using new-style headers) esac ], [AC_MSG_RESULT(Config default: using new-style headers)] ) else AC_DEFINE(_STLP_NO_NEW_STYLE_HEADERS) fi if test "$ac_cv_newstreams" = yes; then AC_ARG_ENABLE(new-iostreams,[--enable-new-iostreams Use new iostreams (default) --disable-new-iostreams Don't use new iostreams], [ case "$enableval" in no) AC_DEFINE(_STLP_NO_NEW_IOSTREAMS) AC_MSG_RESULT(Config arg --disable-new-iostreams : not using new iostreams);; *) AC_MSG_RESULT(Config default: using new iostreams) esac ], [AC_MSG_RESULT(Config default: using new iostreams)] ) else AC_DEFINE(_STLP_NO_NEW_IOSTREAMS) fi AC_ARG_ENABLE(sgi-allocators,[--enable-sgi-allocators : set default parameter to SGI-style default alloc, not allocator --disable-sgi-allocators : use allocator if possible], [ case "$enableval" in yes ) AC_MSG_RESULT(Config arg --enable-sgi-allocators : SGI-style alloc as default allocator) AC_DEFINE(_STLP_USE_RAW_SGI_ALLOCATORS);; * ) AC_MSG_RESULT(Config default: using allocator as default allocator if possible ) esac ], [ AC_MSG_RESULT(Config default: using allocator as default allocator if possible) ] ) AC_ARG_ENABLE(malloc,[--enable-malloc : set default alloc to malloc-based allocator ( malloc_alloc_template, alloc.h ) --disable-malloc : choose (default) sgi node allocator (__alloc alloc.h )], [ case "$enableval" in yes ) AC_MSG_RESULT(Config arg --enable-malloc : setting malloc_alloc as default alloc) AC_DEFINE(_STLP_USE_MALLOC);; * ) AC_MSG_RESULT(Config default: not using malloc_alloc as default alloc) esac ], [ AC_MSG_RESULT(Config default: not using malloc_alloc as default alloc) ] ) AC_ARG_ENABLE(newalloc,[--enable-newalloc : set default alloc to new-based allocator ( new_alloc, alloc.h ) --disable-newalloc : choose (default) sgi allocator (__alloc alloc.h )], [ case "$enableval" in yes ) AC_MSG_RESULT(Config arg --enable-newalloc : setting new_alloc as default alloc) AC_DEFINE(_STLP_USE_NEWALLOC);; * ) AC_MSG_RESULT(Config default: not using new_alloc as default alloc) esac ], [ AC_MSG_RESULT(Config default: not using new_alloc as default alloc) ] ) AC_ARG_ENABLE(defalloc,[--enable-defalloc : make HP-style defalloc.h included in alloc.h ) --disable-defalloc : leave defalloc.h alone], [ case "$enableval" in no ) AC_MSG_RESULT(Config arg --disable-defalloc : not including HP-style defalloc.h into alloc.h);; * ) AC_MSG_RESULT(Config default : including HP-style defalloc.h into alloc.h) AC_DEFINE(_STLP_USE_DEFALLOC) esac ], [ AC_MSG_RESULT(Config default : not including HP-style defalloc.h into alloc.h) ] ) AC_ARG_ENABLE(debugalloc,[--enable-debugalloc : use debug versions of allocators --disable-debugalloc : not using debug allocators], [ case "$enableval" in yes ) AC_MSG_RESULT(Config arg --enable-debugalloc : use debug versions of allocators ) AC_DEFINE(_STLP_DEBUG_ALLOC);; * ) AC_MSG_RESULT(Config default : not using debug allocators) esac ], [ AC_MSG_RESULT(Config default : not using debug allocators) ] ) AC_ARG_ENABLE(abbrevs,[--enable-abbrevs : use abbreviated class names internally for linker benefit (don't affect interface) --disable-abbrevs : don't use abbreviated names], [ case "$enableval" in yes ) AC_MSG_RESULT(Config arg --enable-abbrevs : using abbreviated class names internally) AC_DEFINE(_STLP_USE_ABBREVS);; * ) AC_MSG_RESULT(Config default : not using abbreviated class names internally) esac ], [ AC_MSG_RESULT(Config default : not using abbreviated class names internally) ] ) AC_DEFINE(__AUTO_CONFIGURED) AC_MSG_RESULT(***) AC_MSG_RESULT($0: setting up headers...) AC_MSG_RESULT(***) AC_OUTPUT(stlconf.h) AC_MSG_RESULT(***) AC_MSG_RESULT($0: STLport configured for use with \"${CXX}\" compiler, CXXFLAGS used: \"${CXXFLAGS}\".) AC_MSG_RESULT($0: To restore original settings - run \"./unconfigure\" or copy stlconf.h.in to stlconf.h.) AC_MSG_RESULT(***)