1 // Setup for tests that use result of stl namespace test.
2 #if defined(KWSYS_STL_HAVE_STD)
3 # if KWSYS_STL_HAVE_STD
10 // Setup for tests that use iostreams.
11 #if defined(KWSYS_IOS_USE_ANSI) && defined(KWSYS_IOS_HAVE_STD)
12 # if defined(_MSC_VER)
13 # pragma warning (push,1)
15 # if KWSYS_IOS_USE_ANSI
18 # include <iostream.h>
20 # if defined(_MSC_VER)
21 # pragma warning (pop)
23 # if KWSYS_IOS_HAVE_STD
24 # define kwsys_ios std
30 #ifdef TEST_KWSYS_STL_HAVE_STD
32 void f(std ::list
<int>*) {}
33 int main() { return 0; }
36 #ifdef TEST_KWSYS_IOS_USE_ANSI
38 int main() { return 0; }
41 #ifdef TEST_KWSYS_IOS_HAVE_STD
43 void f(std ::ostream
*) {}
44 int main() { return 0; }
47 #ifdef TEST_KWSYS_IOS_USE_SSTREAM
49 #if defined(__GNUC__) && __GNUC__ == 2 && __GNUC_MINOR__ == 96
50 # error "GCC 2.96 stringstream is buggy"
54 std ::ostringstream ostr
;
56 if(ostr
.str().size() == 5)
64 #ifdef TEST_KWSYS_IOS_USE_STRSTREAM_H
65 #include <strstream.h>
66 int main() { return 0; }
69 #ifdef TEST_KWSYS_IOS_USE_STRSTREA_H
71 int main() { return 0; }
74 #ifdef TEST_KWSYS_STL_STRING_HAVE_OSTREAM
75 # include <iostream.h>
77 void f(ostream
& os
, const kwsys_stl::string
& s
) { os
<< s
; }
78 int main() { return 0; }
81 #ifdef TEST_KWSYS_STL_STRING_HAVE_ISTREAM
82 # include <iostream.h>
84 void f(istream
& is
, kwsys_stl::string
& s
) { is
>> s
; }
85 int main() { return 0; }
88 #ifdef TEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR
90 bool f(const kwsys_stl::string
& s
) { return s
!= ""; }
91 int main() { return 0; }
94 #ifdef TEST_KWSYS_CXX_HAS_CSTDDEF
97 int main() { return 0; }
100 #ifdef TEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS
101 template <class T
> class A
;
102 template <class T
> int f(A
<T
>&);
103 template <class T
> class A
106 // "friend int f<>(A<T>&)" would conform
112 template <class T
> int f(A
<T
>& a
) { return a
.x
= 0; }
113 template int f(A
<int>&);
122 #ifdef TEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES
129 template <class V
> V
m(V
* p
) { return *p
= u
; }
140 #ifdef TEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION
141 template <class T
> struct A
{};
142 template <> struct A
<int*>
144 static int f() { return 0; }
146 int main() { return A
<int*>::f(); }
149 #ifdef TEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP
153 int f(A
*) { return 0; }
163 #ifdef TEST_KWSYS_STL_HAS_ITERATOR_TRAITS
166 void f(kwsys_stl::iterator_traits
<kwsys_stl::list
<int>::iterator
>::iterator_category
const&) {}
167 int main() { return 0; }
170 #ifdef TEST_KWSYS_STL_HAS_ITERATOR_CATEGORY
173 void f(kwsys_stl::list
<int>::iterator x
) { kwsys_stl::iterator_category(x
); }
174 int main() { return 0; }
177 #ifdef TEST_KWSYS_STL_HAS___ITERATOR_CATEGORY
180 void f(kwsys_stl::list
<int>::iterator x
) { kwsys_stl::__iterator_category(x
); }
181 int main() { return 0; }
184 #ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE
186 template <class Alloc
>
189 typedef typename
Alloc::size_type alloc_size_type
;
193 f(kwsys_stl::allocator
<char>());
198 #ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE
200 void f(kwsys_stl::allocator::size_type
const&) {}
201 int main() { return 0; }
204 #ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_REBIND
206 template <class T
, class Alloc
>
207 void f(const T
&, const Alloc
&)
209 typedef typename
Alloc::template rebind
<T
>::other alloc_type
;
213 f(0, kwsys_stl::allocator
<char>());
218 #ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT
220 void f(kwsys_stl::allocator
<char> const& a
)
222 a
.max_size(sizeof(int));
226 f(kwsys_stl::allocator
<char>());
231 #ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS
233 void f(kwsys_stl::vector
<int> const& v1
)
235 kwsys_stl::vector
<int>(1, 1, v1
.get_allocator());
239 f(kwsys_stl::vector
<int>());
244 #ifdef TEST_KWSYS_STAT_HAS_ST_MTIM
245 #include <sys/types.h>
246 #include <sys/stat.h>
251 (void)stat1
.st_mtim
.tv_sec
;
252 (void)stat1
.st_mtim
.tv_nsec
;
257 #ifdef TEST_KWSYS_CXX_SAME_LONG_AND___INT64
258 void function(long**) {}
267 #ifdef TEST_KWSYS_CXX_SAME_LONG_LONG_AND___INT64
268 void function(long long**) {}
277 #ifdef TEST_KWSYS_CAN_CONVERT_UI64_TO_DOUBLE
278 void function(double& l
, unsigned __int64
const& r
)
280 l
= static_cast<double>(r
);
286 unsigned __int64 tFrom
= 0;
287 function(tTo
, tFrom
);
292 #ifdef TEST_KWSYS_IOS_HAS_ISTREAM_LONG_LONG
293 int test_istream(kwsys_ios::istream
& is
, long long& x
)
295 return (is
>> x
)? 1:0;
300 return test_istream(kwsys_ios::cin
, x
);
304 #ifdef TEST_KWSYS_IOS_HAS_OSTREAM_LONG_LONG
305 int test_ostream(kwsys_ios::ostream
& os
, long long x
)
307 return (os
<< x
)? 1:0;
312 return test_ostream(kwsys_ios::cout
, x
);
316 #ifdef TEST_KWSYS_CHAR_IS_SIGNED
317 /* Return 0 for char signed and 1 for char unsigned. */
320 unsigned char uc
= 255;
321 return (*reinterpret_cast<char*>(&uc
) < 0)?0:1;
325 #ifdef TEST_KWSYS_LFS_WORKS
326 /* Return 0 when LFS is available and 1 otherwise. */
327 #define _LARGEFILE_SOURCE
328 #define _LARGEFILE64_SOURCE
330 #define _FILE_OFFSET_BITS 64
331 #include <sys/types.h>
332 #include <sys/stat.h>
336 int main(int, char **argv
)
338 /* check that off_t can hold 2^63 - 1 and perform basic operations... */
339 #define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
340 if (OFF_T_64
% 2147483647 != 1)
343 // stat breaks on SCO OpenServer
345 stat( argv
[0], &buf
);
346 if (!S_ISREG(buf
.st_mode
))
349 FILE *file
= fopen( argv
[0], "r" );
350 off_t offset
= ftello( file
);
351 fseek( file
, offset
, SEEK_CUR
);
357 #ifdef TEST_KWSYS_CXX_TYPE_INFO
358 /* Collect fundamental type information and save it to a CMake script. */
360 /* Include limits.h to get macros indicating long long and __int64.
361 Note that certain compilers need special macros to define these
362 macros in limits.h. */
363 #if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
364 # define _MSC_EXTENSIONS
366 #if defined(__GNUC__) && __GNUC__ < 3
374 /* Due to shell differences and limitations of ADD_DEFINITIONS the
375 KWSYS_CXX_TYPE_INFO_FILE macro will sometimes have double quotes
376 and sometimes not. This macro will make sure the value is treated
377 as a double-quoted string. */
378 #define TO_STRING(x) TO_STRING0(x)
379 #define TO_STRING0(x) TO_STRING1(x)
380 #define TO_STRING1(x) #x
386 /* Construct the output file name. Some preprocessors will add an
387 extra level of double quotes, so strip them. */
388 char fbuf
[] = TO_STRING(KWSYS_CXX_TYPE_INFO_FILE
);
393 int len
= static_cast<int>(strlen(fname
));
394 if(len
> 0 && fname
[len
-1] == '"')
400 /* Try to open the output file. */
401 if(FILE* fout
= fopen(fname
, "w"))
403 /* Set the size of standard types. */
404 fprintf(fout
, "SET(KWSYS_SIZEOF_CHAR %d)\n", static_cast<int>(sizeof(char)));
405 fprintf(fout
, "SET(KWSYS_SIZEOF_SHORT %d)\n", static_cast<int>(sizeof(short)));
406 fprintf(fout
, "SET(KWSYS_SIZEOF_INT %d)\n", static_cast<int>(sizeof(int)));
407 fprintf(fout
, "SET(KWSYS_SIZEOF_LONG %d)\n", static_cast<int>(sizeof(long)));
409 /* Set the size of some non-standard but common types. */
410 /* Check for a limits.h macro for long long to see if the type exists. */
411 #if defined(LLONG_MAX) || defined(LONG_LONG_MAX) || defined(LONGLONG_MAX)
412 fprintf(fout
, "SET(KWSYS_SIZEOF_LONG_LONG %d)\n", static_cast<int>(sizeof(long long)));
414 fprintf(fout
, "SET(KWSYS_SIZEOF_LONG_LONG 0) # No long long available.\n");
416 /* Check for a limits.h macro for __int64 to see if the type exists. */
417 #if defined(_I64_MIN)
418 fprintf(fout
, "SET(KWSYS_SIZEOF___INT64 %d)\n", static_cast<int>(sizeof(__int64
)));
420 fprintf(fout
, "SET(KWSYS_SIZEOF___INT64 0) # No __int64 available.\n");
423 /* Set the size of some pointer types. */
424 fprintf(fout
, "SET(KWSYS_SIZEOF_PDATA %d)\n", static_cast<int>(sizeof(void*)));
425 fprintf(fout
, "SET(KWSYS_SIZEOF_PFUNC %d)\n", static_cast<int>(sizeof(&f
)));
427 /* Set whether the native type "char" is signed or unsigned. */
428 unsigned char uc
= 255;
429 fprintf(fout
, "SET(KWSYS_CHAR_IS_SIGNED %d)\n",
430 (*reinterpret_cast<char*>(&uc
) < 0)?1:0);
437 fprintf(stderr
, "Failed to write fundamental type info to \"%s\".\n",