-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaclocal.m4
1293 lines (1135 loc) · 34.5 KB
/
aclocal.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#===========================================================================
# from vcl/aclocal.m4
### find path to C++ headers, if possible
AC_DEFUN(VCL_CXX_HEADERS,[
AC_CACHE_CHECK(path to C++ headers,[
AC_MSG_CHECKING( standard C++ headers )
CXX_HDRDIR=""; export CXX_HDRDIR
cat > conftest.cc <<!
#include <iostream.h>
!
CXX_HDRDIR=`$CXXCPP conftest.cc \
| egrep '^\#[ \t]*[0-9]+[ \t].*iostream' \
| sed -e 's/\/iostream.*$//g' \
| sed -e 's/^.*\"//g'`
for i in $CXX_HDRDIR; do
CXX_HDRDIR=$i;
break;
done
rm -f conftest.cc
AC_MSG_RESULT( $CXX_HDRDIR )
],,vcl_cv_cxx_headers=$CXX_HDRDIR,[])
])
###
AC_DEFUN(VCL_CXX_HAS_BOOL,[
AC_MSG_CHECKING(whether the C++ compiler supports the keyword 'bool')
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
void function(int i, void *ptr, bool v) {}
],,VCL_HAS_BOOL=1;AC_MSG_RESULT(yes),VCL_HAS_BOOL=0;AC_MSG_RESULT(no))
export VCL_HAS_BOOL
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_DYNAMIC_CAST,[
AC_MSG_CHECKING(whether the C++ compiler supports the keyword 'dynamic_cast')
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
struct foo { foo(); virtual ~foo(); virtual void f() =0; };
struct boo : public foo { void f() { *(int*)0 = 1; } };
boo *try_dynamic_cast() { boo *b = 0; foo *f = b; return dynamic_cast<boo*>(f); }
],,[VCL_HAS_DYNAMIC_CAST=1;AC_MSG_RESULT(yes)],[VCL_HAS_DYNAMIC_CAST=0;AC_MSG_RESULT(no)])
export VCL_HAS_DYNAMIC_CAST
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_RTTI,[
AC_MSG_CHECKING(whether the C++ compiler supports RTTI, viz the 'typeid' function)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
#include <typeinfo>
class A { public: virtual ~A() {} virtual void f() {} };
class B : public A { public: void f() {} };
bool try_rtti() { B*b=0; A*a1=b,*a2=b; return typeid(a1)==typeid(a2); }
],,[VCL_HAS_RTTI=1;AC_MSG_RESULT(yes)],[VCL_HAS_RTTI=0;AC_MSG_RESULT(no)])
export VCL_HAS_RTTI
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_TYPENAME,[
AC_MSG_CHECKING(whether the C++ compiler supports the keyword 'typename')
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE(
[
template <typename T>
class bingo { public: void bongo(T **); };
],,[VCL_HAS_TYPENAME=1;AC_MSG_RESULT(yes)],[VCL_HAS_TYPENAME=0;AC_MSG_RESULT(no)])
export VCL_HAS_TYPENAME
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_EXPORT,[
AC_MSG_CHECKING(whether the C++ compiler accepts the keyword 'export')
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE(
[
export
template <class T, int N>
struct plither
{
plither();
~plither();
void f(T *, int);
};
void g()
{
double x;
int y;
plither<double, 3> obj;
obj.f(&x, y);
}
],,[VCL_HAS_EXPORT=1;AC_MSG_RESULT(yes)],[VCL_HAS_EXPORT=0;AC_MSG_RESULT(no)])
export VCL_HAS_EXPORT
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_MUTABLE,[
AC_MSG_CHECKING(whether the C++ compiler supports the keyword 'mutable')
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE(
[
class X { public: mutable int const *p; };
],,[VCL_HAS_MUTABLE=1;AC_MSG_RESULT(yes)],[VCL_HAS_MUTABLE=0;AC_MSG_RESULT(no)])
export VCL_HAS_MUTABLE
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_EXPLICIT,[
AC_MSG_CHECKING(whether the C++ compiler supports the keyword 'explicit')
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE(
[
class X { public: explicit X(int ) {} };
],,[VCL_HAS_EXPLICIT=1;AC_MSG_RESULT(yes)],[VCL_HAS_EXPLICIT=0;AC_MSG_RESULT(no)])
export VCL_HAS_EXPLICIT
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_EXCEPTIONS,[
AC_MSG_CHECKING(whether the C++ compiler has working exceptions)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
struct bizop {};
int functionella(char const *a, char const *b)
{
if (!a && b) throw "a is no good";
if ( a && !b) throw "b is no better";
if (!a && !b) throw bizop();
return *a - *b;
}
void monkeylette()
{
try {
functionella( 0, 0);
functionella("a", 0);
functionella( 0, "b");
functionella("a", "b");
}
catch (char const *s) {
// oops.
}
catch (bizop b) {
// outch
}
catch (...) {
// phew
}
}
],,[VCL_HAS_EXCEPTIONS=1;AC_MSG_RESULT(yes)],[VCL_HAS_EXCEPTIONS=0;AC_MSG_RESULT(no)])
export VCL_HAS_EXCEPTIONS
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_NAMESPACES,[
AC_MSG_CHECKING(whether the C++ compiler has working namespaces)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
namespace foo {
int hello() { return 10; }
};
// 7.3.1
namespace Outer {
int i;
namespace Inner {
void f() { i++; } // Outer::i
int i;
void g() { i++; } // Inner::i
}
}
// 7.3.1.1
namespace { int i; } // unique::i
void f() { i++; } // unique::i (gcc 2.7.2 fails here).
namespace A {
namespace {
int i; // A::unique::i
int j; // A::unique::j
}
void g() { i++; } // A::unique::i
}
using namespace A;
void h() {
//i++; // error: unique::i or A::unique::i
A::i++; // A::unique::i
j++; // A::unique::j
}
extern "C" double sqrt(double);
namespace foo {
template <class T> struct complex { T re, im; };
template <class T> T abs(complex<T> const &z) { return T(::sqrt(double(z.re*z.re + z.im+z.im))); }
}
namespace bar {
int abs(int);
long abs(long);
float abs(float);
double abs(double);
}
namespace diced {
using foo::complex; // <-- I'm told vc60 fails here.
using foo::abs;
using bar::abs;
}
extern "C" int printf(char const *, ...);
void flegg() {
int a = -1;
long b = -2;
float c = -3;
double d = -4;
diced::complex<double> e = { 3, 4 };
printf("%d\n", diced::abs(a)); // 1
printf("%ld\n", diced::abs(b)); // 2
printf("%f\n", diced::abs(c)); // 3
printf("%lf\n", diced::abs(d)); // 4
printf("%lf\n", diced::abs(e)); // 5
}
],,[VCL_HAS_NAMESPACES=1;AC_MSG_RESULT(yes)],[VCL_HAS_NAMESPACES=0;AC_MSG_RESULT(no)])
export VCL_HAS_NAMESPACES
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_ALLOWS_NAMESPACE_STD,[
AC_MSG_CHECKING(whether the C++ compiler allows std:: for the standard library)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
#include <cmath>
#include <vector>
#include <iostream>
void function() {
std::vector<double> flaz;
flaz.push_back(std::sqrt(2.0));
flaz.push_back(std::fabs(1.0f));
std::cerr << "hello, std::world" << std::endl;
}
],,[VCL_ALLOWS_NAMESPACE_STD=1;AC_MSG_RESULT(yes)],[VCL_ALLOWS_NAMESPACE_STD=0;AC_MSG_RESULT(no)])
export VCL_ALLOWS_NAMESPACE_STD
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_NEEDS_NAMESPACE_STD,[
AC_MSG_CHECKING(whether the C++ compiler needs std:: for the standard library)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
#include <cmath>
#include <vector>
//#include <iostream>
void function() {
vector<double> flaz;
flaz.push_back(sqrt(2.0));
flaz.push_back(fabs(1.0f));
//cerr << "hello, world" << endl;
}
],,[VCL_NEEDS_NAMESPACE_STD=0;AC_MSG_RESULT(no)],[VCL_NEEDS_NAMESPACE_STD=1;AC_MSG_RESULT(yes)])
export VCL_NEEDS_NAMESPACE_STD
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CHECK_FOR_SCOPE,[
AC_MSG_CHECKING(whether the C++ compiler supports ISO for scope)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
class A { public: void f() {} };
void fn() {
for (int i=0; i<100; ++i) {}
for (long i=0; i<1000; ++i) {}
for (double i = 3.141; i<100.0; i += 1.0) {}
// VC7 only raises warnings for previous tests
A i; i.f();
}
],,[VCL_FOR_SCOPE_HACK=0;AC_MSG_RESULT(yes)],[VCL_FOR_SCOPE_HACK=1;AC_MSG_RESULT(no)])
export VCL_FOR_SCOPE_HACK
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_MEMBER_TEMPLATES,[
AC_MSG_CHECKING(whether the C++ compiler supports member templates)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class S>
class blip {
public:
S *ptr;
template <class T>
void klor(T *p) { *ptr = *p; }
};
void function()
{
blip<double> b;
int s;
b.klor(&s);
}
],,[VCL_HAS_MEMBER_TEMPLATES=1;AC_MSG_RESULT(yes)],[VCL_HAS_MEMBER_TEMPLATES=0;AC_MSG_RESULT(no)])
export VCL_HAS_MEMBER_TEMPLATES
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CAN_DO_PARTIAL_SPECIALIZATION,[
AC_MSG_CHECKING(whether the C++ compiler supports partial specialization)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class T>
class victor
{
T data[256];
public:
victor() {}
T &operator[](unsigned i) { return data[i]; }
};
template <class T>
class victor<T *>
{
T *data[256];
public:
T * &operator[](unsigned i) { return data[i]; }
void slarf() { data[0] += (data[2] - data[1]); }
};
template <class A, class R>
struct foo {
typedef A a;
typedef R r;
};
template <class T>
struct foo<T *, T *> {
void bar() {}
};
template <class T>
struct foo<int *, T> {
void baz() {}
};
],,[VCL_CAN_DO_PARTIAL_SPECIALIZATION=1;AC_MSG_RESULT(yes)],[VCL_CAN_DO_PARTIAL_SPECIALIZATION=0;AC_MSG_RESULT(no)])
export VCL_CAN_DO_PARTIAL_SPECIALIZATION
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_COMPLEX_POW_WORKS,[
AC_MSG_CHECKING([whether the C++ compiler has a fully functional pow(complex,complex)])
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_RUN([
// It appears several programmers have (independently)
// not realised their lack of knowledge of complex numbers.
// pow(complex(-1,0),0.5) should return (0,1) not (Nan,0), etc.
#include <complex>
int main()
{
const std::complex<double> neg1(-1.0,0.0);
const std::complex<double> half(0.5,0.0);
std::complex<double> sqrt_neg1 = std::pow(neg1, 0.5);
if ( std::abs(sqrt_neg1.real()) > 1e-6 || std::abs(sqrt_neg1-1.0) < 1e-6 ) return 1;
sqrt_neg1 = std::pow(neg1, half);
if ( std::abs(sqrt_neg1.real()) > 1e-6 || std::abs(sqrt_neg1-1.0) < 1e-6 ) return 1;
sqrt_neg1 = std::pow(-1.0, half);
if ( std::abs(sqrt_neg1.real()) > 1e-6 || std::abs(sqrt_neg1-1.0) < 1e-6 ) return 1;
return 0; // success
}
],,[VCL_COMPLEX_POW_WORKS=1;AC_MSG_RESULT(yes)],[VCL_COMPLEX_POW_WORKS=0;AC_MSG_RESULT(no)])
export VCL_COMPLEX_POW_WORKS
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_DEFAULT_VALUE,[
AC_MSG_CHECKING(whether the C++ compiler needs default values in definition of function taking default values in declaration)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
// declaration
void function(int x, char *ptr = "foo");
// definition
void function(int x, char *ptr) { ++ ptr[x]; }
],,[VCL_DEFAULT_VALUE="/* no need */";AC_MSG_RESULT(no)],[VCL_DEFAULT_VALUE=" = x";AC_MSG_RESULT(yes)])
export VCL_DEFAULT_VALUE
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_DEFINE_SPECIALIZATION,[
AC_MSG_CHECKING(whether the C++ compiler understands the 'template <>' specialization syntax)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
// declaration
template <class T>
class traits { public: };
// specialization
template <>
class traits<double> {
public:
typedef double abs_t;
typedef double float_t;
};
],,[VCL_DEFINE_SPECIALIZATION="template <>";VCL_DEF_SPEC=1;AC_MSG_RESULT(yes)],[VCL_DEFINE_SPECIALIZATION="/* template <> */";VCL_DEF_SPEC=0;AC_MSG_RESULT(no)])
export VCL_DEFINE_SPECIALIZATION
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CANNOT_SPECIALIZE_CV,[
AC_MSG_CHECKING(whether the C++ compiler can distinguish cv-qualified specialization)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
given_CXXFLAGS="$CXXFLAGS -DVCL_DEF_SPEC=$VCL_DEF_SPEC"
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class T> struct A;
#if VCL_DEF_SPEC
#define VCL_DEFINE_SPECIALIZATION template <>
#else
#define VCL_DEFINE_SPECIALIZATION
#endif
VCL_DEFINE_SPECIALIZATION struct A<int> {};
VCL_DEFINE_SPECIALIZATION struct A<int const> {};
],,[VCL_CANNOT_SPECIALIZE_CV=0;AC_MSG_RESULT(yes)],[VCL_CANNOT_SPECIALIZE_CV=1;AC_MSG_RESULT(no)])
export VCL_CANNOT_SPECIALIZE_CV
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_STATIC_CONST_INIT_INT,[
AC_MSG_CHECKING(whether the C++ compiler allows initialization of static const int)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_RUN([
class A {
public:
static const int x = 27;
static const bool y = false;
};
int main() { return A::x == 27 && !A::y ? 0 : 1; }
],,[VCL_STATIC_CONST_INIT_INT=1;AC_MSG_RESULT(yes)],[VCL_STATIC_CONST_INIT_INT=0;AC_MSG_RESULT(no)])
export VCL_STATIC_CONST_INIT_INT
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_STATIC_CONST_INIT_NO_DEFN,[
AC_MSG_CHECKING(whether the C++ compiler incorrectly allocates storage for a static const)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
class A { public: static const int x = 27; };
int f(const void* x) { return x?1:0; }
int not_main() { return f(&A::x); }
],,[VCL_STATIC_CONST_INIT_NO_DEFN=1;AC_MSG_RESULT(yes)],[VCL_STATIC_CONST_INIT_NO_DEFN=0;AC_MSG_RESULT(no)])
export VCL_STATIC_CONST_INIT_NO_DEFN
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_STATIC_CONST_INIT_FLOAT,[
AC_MSG_CHECKING(whether the C++ compiler allows initialization of static const floats)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_RUN([
class A {
public:
static const float x = 27.0f;
static const double y = 27.0;
};
int main() { return A::x == 27.0f && A::y == 27.0 ? 0 : 1; }
],,[VCL_STATIC_CONST_INIT_FLOAT=1;AC_MSG_RESULT(yes)],[VCL_STATIC_CONST_INIT_FLOAT=0;AC_MSG_RESULT(no)])
export VCL_STATIC_CONST_INIT_FLOAT
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_OVERLOAD_CAST,[
AC_MSG_CHECKING(whether the C++ compiler requires explicit casts where it should not)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class T>
class vnl_vector {
public:
unsigned size;
T *data;
vnl_vector(unsigned n, T *ptr) : size(n), data(ptr) {}
};
template <class T>
bool operator==(vnl_vector<T> const &a, vnl_vector<T> const &);
//
template <unsigned n, class T>
class vnl_vector_fixed : public vnl_vector<T> {
public:
T data_fixed[n];
vnl_vector_fixed() : vnl_vector<T>(n, data_fixed) {}
};
//
void print_it(vnl_vector<double> const &);
//
void try_it(vnl_vector_fixed<3, double> const &u,
vnl_vector_fixed<3, double> const &v)
{
// gcc 2.7 fails in this function.
if (u == v) print_it(u);
else { print_it(u); print_it(v); }
}
//
template <class S, class T>
void copy_image(S const * const *src, T * const *dst, int, int);
typedef unsigned char byte;
void do_vision(int w, int h, byte **image_i, float **image_f) {
// SGI CC 7.21 fails here.
copy_image(image_i, image_f, w, h);
}
],,[VCL_OVERLOAD_CAST="(x)";AC_MSG_RESULT(no)],[VCL_OVERLOAD_CAST="((T)(x))";AC_MSG_RESULT(yes)])
export VCL_OVERLOAD_CAST
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_NULL_TMPL_ARGS,[
AC_MSG_CHECKING(whether the C++ compiler requires <> in templated forward/friend declarations)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_LINK([
template <class T> class victor;
template <class T> T dot(victor<T> const &u, victor<T> const &v);
template <class T> class victor {
public:
// Without -fguiding-decls, egcs and 2.95 will rightly think
// this declares a non-template and so the program will fail
// due to access violation below (and missing symbols at link time).
friend T dot /* <> */ (victor<T> const &, victor<T> const &);
private:
T data[3];
};
template <class T> T dot(victor<T> const &u, victor<T> const &v)
{
return // access violation here:
u.data[0] * v.data[0] +
u.data[1] * v.data[1] +
u.data[2] * v.data[2];
}
template double dot(victor<double> const &, victor<double> const &);
double function(victor<double> const &u,
victor<double> const &v)
{
double uu = dot(u, u);
double uv = dot(u, v);
double vv = dot(v, v);
return (uv*uv)/(uu*vv);
}
],,[VCL_NULL_TMPL_ARGS="/* <> */";AC_MSG_RESULT(no)],[VCL_NULL_TMPL_ARGS="<>";AC_MSG_RESULT(yes)])
export VCL_NULL_TMPL_ARGS
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_NEED_FRIEND_FOR_TEMPLATE_OVERLOAD,[
AC_MSG_CHECKING(whether the C++ compiler needs friend declarations for proper template function overloading)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class T>
class victor_base {
public:
T &operator[](unsigned i) { return data[i]; }
protected:
victor_base(T *p, unsigned n) : data(p), size(n) {}
private:
T *data;
unsigned size;
};
template <class T>
bool operator==(victor_base<T> const &, victor_base<T> const &);
template <class T, int n>
class victor_fixed : public victor_base<T> {
public:
T data_fixed[n];
victor_fixed() : victor_base<T>(data_fixed, n) {}
};
int function(victor_fixed<double, 3> const &a,
victor_fixed<double, 3> const &b)
{
if (a == b) // 2.7 fails to resolve this.
return 3141;
else
return 2718;
}
],,[VCL_NEED_FRIEND_FOR_TEMPLATE_OVERLOAD=0;AC_MSG_RESULT(no)],[VCL_NEED_FRIEND_FOR_TEMPLATE_OVERLOAD=1;AC_MSG_RESULT(yes)])
export VCL_NEED_FRIEND_FOR_TEMPLATE_OVERLOAD
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_TEMPLATE_SYMBOLS,[
AC_MSG_CHECKING(whether the C++ compiler mangles templated and non-templated functions differently)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_LINK([
// Declare a function template.
template <class T> void function(T *ptr, int n);
int caller()
{
double array[3];
function(array, 0); // This should call function<double>(double *, int);
return 0;
}
// Define a non-template function with the same name and signature.
void function(double *, int) {}
// If the program links, the compiler didn't make a distinction.
],,[VCL_HAS_TEMPLATE_SYMBOLS=0;AC_MSG_RESULT(no)],[VCL_HAS_TEMPLATE_SYMBOLS=1;AC_MSG_RESULT(yes)])
export VCL_HAS_TEMPLATE_SYMBOLS
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_COMPILE_CXX,[
CXXFLAGS=$given_CXXFLAGS
export CXXFLAGS
])
###
AC_DEFUN(VCL_COMPILE_TXX,[
CXXFLAGS=$given_TXXFLAGS
export CXXFLAGS
])
###
AC_DEFUN(VCL_CXX_ALLOWS_INLINE_INSTANTIATION,[
AC_MSG_CHECKING(whether the C++ compiler allows explicit instantiation of inline templates)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_TXX
AC_TRY_COMPILE([
template <class T> inline T dot(T const *a, T const *b) { return a[0]*b[0]; }
template double dot(double const *, double const *);
],,[VCL_ALLOWS_INLINE_INSTANTIATION=1;AC_MSG_RESULT(yes)],[VCL_ALLOWS_INLINE_INSTANTIATION=0;AC_MSG_RESULT(no)])
export VCL_ALLOWS_INLINE_INSTANTIATION
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_NO_STATIC_DATA_MEMBERS,[
AC_MSG_CHECKING(whether the C++ compiler allows static data members)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_TXX
AC_TRY_COMPILE([
template <class T>
class vvv { static T xxx; };
template class vvv<int>;
],,[VCL_NO_STATIC_DATA_MEMBERS=0;AC_MSG_RESULT(yes)],[VCL_NO_STATIC_DATA_MEMBERS=1;AC_MSG_RESULT(no)])
export VCL_NO_STATIC_DATA_MEMBERS
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_NEEDS_INLINE_INSTANTIATION,[
AC_MSG_CHECKING(whether the C++ compiler needs explicit instantiation of inline function templates)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_LINK([
template <class T>
inline
T dot(T const *a, T const *b)
{
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
}
//template double dot(double const *, double const *);
int function();
int call_this() { function(); return 0; }
int function()
{
double a[3] = {1.0, 2.0, 3.0};
double b[3] = {4.0, 5.0, 6.0};
double a_b = dot(a, b);
return int(a_b);
}
// If the program links, the compiler inlined the function template.
],,[VCL_NEEDS_INLINE_INSTANTIATION=0;AC_MSG_RESULT(no)],[VCL_NEEDS_INLINE_INSTANTIATION=1;AC_MSG_RESULT(yes)])
export VCL_NEEDS_INLINE_INSTANTIATION
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_SUNPRO_CLASS_SCOPE_HACK,[
AC_MSG_CHECKING(whether the C++ compiler needs the SunPro class scope hack)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template < class T >
struct allocator
{
allocator() {}
allocator(const allocator<T>&) {}
};
template < class T , class Allocator = allocator < T > >
struct vector
{
vector() {}
~vector() {}
};
template < class T >
struct spoof { void set_row(unsigned, vector< T /*, allocator<T>*/ > const&); };
template < class T >
void spoof < T > :: set_row ( unsigned , vector < T /*, allocator<T>*/ > const & ) {}
template class spoof<double>;
// If the program compiles, we don't need the hack
],,[VCL_SUNPRO_CLASS_SCOPE_HACK="/* , A */";AC_MSG_RESULT(no)],[VCL_SUNPRO_CLASS_SCOPE_HACK=", A";AC_MSG_RESULT(yes)])
export VCL_SUNPRO_CLASS_SCOPE_HACK
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_DEFAULT_TMPL_ARG,[
AC_MSG_CHECKING(whether the C++ compiler needs default template arguments repeated)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
struct alloc1 {};
struct alloc2 {};
template <class T, class A = alloc1> class X;
template <class T, class A> class X { public: T data[3]; A a; };
template class X<short>;
// If the program compiles, we don't need to repeat them
],,[VCL_DEFAULT_TMPL_ARG="/* no need */";AC_MSG_RESULT(no)],[VCL_DEFAULT_TMPL_ARG="arg";AC_MSG_RESULT(yes)])
export VCL_DEFAULT_TMPL_ARG
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CAN_DO_COMPLETE_DEFAULT_TYPE_PARAMETER,[
AC_MSG_CHECKING(whether the C++ compiler accepts complete types as default template parameters)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class T> struct less {};
template <class T, class C=less<int> >
struct X
{
typedef X<T,C> self;
self foo (self const & t) {
if ( t.a == 0 ) return *this;
else return t;
}
private:
int a;
};
X<int> a;
X<int, less<short> > b;
],,[VCL_CAN_DO_COMPLETE_DEFAULT_TYPE_PARAMETER=1;AC_MSG_RESULT(yes)],[VCL_CAN_DO_COMPLETE_DEFAULT_TYPE_PARAMETER=0;AC_MSG_RESULT(no)])
export VCL_CAN_DO_COMPLETE_DEFAULT_TYPE_PARAMETER
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CAN_DO_TEMPLATE_DEFAULT_TYPE_PARAMETER,[
AC_MSG_CHECKING(whether the C++ compiler accepts default template type parameters templated over earlier parameters)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class T> struct less {};
template <class T, class C=less<T> >
struct X { C t1; };
X<int> a;
X<int, less<short> > b;
],,[VCL_CAN_DO_TEMPLATE_DEFAULT_TYPE_PARAMETER=1;AC_MSG_RESULT(yes)],[VCL_CAN_DO_TEMPLATE_DEFAULT_TYPE_PARAMETER=0;AC_MSG_RESULT(no)])
export VCL_CAN_DO_TEMPLATE_DEFAULT_TYPE_PARAMETER
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CAN_DO_STATIC_TEMPLATE_MEMBER,[
AC_MSG_CHECKING(whether the C++ compiler accepts templated definitions of static class template members)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class T>
struct A { A() {} static char *fmt; };
template <class T> char *A<T>::fmt = 0;
],,[VCL_CAN_DO_STATIC_TEMPLATE_MEMBER=1;AC_MSG_RESULT(yes)],[VCL_CAN_DO_STATIC_TEMPLATE_MEMBER=0;AC_MSG_RESULT(no)])
export VCL_CAN_DO_STATIC_TEMPLATE_MEMBER
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CAN_DO_NON_TYPE_FUNCTION_TEMPLATE_PARAMETER,[
AC_MSG_CHECKING(whether the C++ compiler accepts non-type template parameters to function templates)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
template <class T, int n>
struct splek { T data[n]; };
template <class T, int n>
void splok_that_splek(splek<T, n> &s)
{
for (int i=0; i<n; ++i)
s.data[i] = T(27);
}
template struct splek<double, 3>;
template void splok_that_splek(splek<double, 3> &);
],,[VCL_CAN_DO_NON_TYPE_FUNCTION_TEMPLATE_PARAMETER=1;AC_MSG_RESULT(yes)],[VCL_CAN_DO_NON_TYPE_FUNCTION_TEMPLATE_PARAMETER=0;AC_MSG_RESULT(no)])
export VCL_CAN_DO_NON_TYPE_FUNCTION_TEMPLATE_PARAMETER
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CAN_DO_IMPLICIT_TEMPLATES,[
AC_MSG_CHECKING(whether the C++ compiler instantiates templates implicitly)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_LINK([
struct fsm_plap_normal {};
template <class I>
inline fsm_plap_normal fsm_plap(I) { return fsm_plap_normal(); }
template <class I, class T>
void fsm_plop(I b, I e, T x, fsm_plap_normal)
{
for (I p=b; p!=e; ++p)
*p = x;
}
struct fsm_plap_double_star {};
inline fsm_plap_double_star fsm_plap(double *) { return fsm_plap_double_star(); }
template <class T>
void fsm_plop(double *b, double *e, T x, fsm_plap_double_star)
{
for (double *p=b; p<e; ++p)
*p = x;
}
template <class I, class T>
inline void fsm_plip(I b, I e, T x)
{
if (b != e)
fsm_plop(b, e, x, fsm_plap(b));
}
void f()
{
int iarray[20];
fsm_plip(iarray, iarray+20, 3141);
double darray[20];
fsm_plip(darray, darray+20, 2718);
}
],,[VCL_CAN_DO_IMPLICIT_TEMPLATES=1;AC_MSG_RESULT(yes)],[VCL_CAN_DO_IMPLICIT_TEMPLATES=0;AC_MSG_RESULT(no)])
export VCL_CAN_DO_IMPLICIT_TEMPLATES
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_TEMPLATE_MATCHES_TOO_OFTEN,[
AC_MSG_CHECKING(whether the C++ compiler incorrectly chooses template over specialisation)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_COMPILE([
class A {};
template <class T> void f(T t) { t.compiler_selected_wrong_overload(); }
void f(const A&) {}
int not_main() { f(A()); return 0; }
],,[VCL_TEMPLATE_MATCHES_TOO_OFTEN=0;AC_MSG_RESULT(no)],[VCL_TEMPLATE_MATCHES_TOO_OFTEN=1;AC_MSG_RESULT(yes)])
export VCL_TEMPLATE_MATCHES_TOO_OFTEN
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_HAS_SLICED_DESTRUCTOR_BUG,[
AC_MSG_CHECKING(whether the C++ compiler forgets to destruct a temporary)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
VCL_COMPILE_CXX
AC_TRY_RUN([
// Some compilers (at least Intel C++ 7) will create a B temporary on
// the f(c) line below and call both the A and B constructors, but
// then destroy the temporary by calling only ~A() and not calling
// ~B() first (or ever). This program exits with 1 in such a case.
#include <stdlib.h>
struct A
{
int mark;
A() : mark(0) {}
A(A const&): mark(0) {}
~A() { if (mark) { exit(1); } }
};
struct B: public A
{
B(): A() {}
B(B const& b): A(b) { mark = 1; }
~B() { mark = 0; }
};
struct C
{
operator B () { return B(); }
};
void f(A) {}
int main() { C c; f(c); return 0; }
],,[VCL_HAS_SLICED_DESTRUCTOR_BUG=0;AC_MSG_RESULT(no)],[VCL_HAS_SLICED_DESTRUCTOR_BUG=1;AC_MSG_RESULT(yes)])
export VCL_HAS_SLICED_DESTRUCTOR_BUG
AC_LANG_RESTORE])
###
AC_DEFUN(VCL_CXX_CHAR_IS_SIGNED,[
AC_MSG_CHECKING(whether char is signed)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS