forked from timotheecour/vitanim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
31 lines (27 loc) · 767 Bytes
/
test.cpp
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
#include <iostream>
// #include "csrc/clib.h"
using namespace std;
// N_CDECL(void, NimMain)(void);
extern "C"
char* hello_echo(char* message);
std::string echo(std::string arg) {
const char* message = arg.c_str();
cout << "C++ passing message: " << message << "\n";
cout << "C++ message addr: " << (void*)message << "\n";
char* retval = hello_echo(
(char *)(message)
);
cout << "C++ retval addr : " << (void*)retval << "\n";
return std::string(retval);
}
int main() {
// NimMain();
cout << "Hello world\n";
int i = 0;
for (i = 0; i < 1000; i++) {
std::string msg = "Hello " + std::string(i, '-');
std::string ret = echo(msg);
cout << "Got reply: " << ret << "\n";
}
return 0;
}