blob: 6677923ac6ffe6f4b82c5eefbf8f52af170d3793 (
plain)
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
|
// External.cpp - useless C++ code calling pascal main.
#include <limits>
#include "MainExports.h"
template <typename T>
struct Horror
{
void Message() { Message(Selector<IsInteger<T>::yes>()); }
private:
template <bool> struct Selector {};
void Message(Selector<true>) {
::Message("\pCalling pascal from template Horror<T> [T=int]");
}
void Message(Selector<false>) { throw 1; }
template <typename I> struct IsInteger
{
enum { yes = std::numeric_limits<I>::is_integer };
};
};
extern "C" {
SInt32 CPlusFunction()
{
try // call pascal from C++ template instances
{
Horror<short>().Message();
Horror<float>().Message();
}
catch (...)
{
Message("\pCalling pascal from a C++ catch");
}
// C++ fun is over, go home to mother pascal :)
return 456;
}
} // extern "C"
|