> On 7 Jan 2015, at 14:52, Matt Wette <[email protected]> wrote:
>
> Python is written in C yet Qt has been integrated in to produce PyQt. I
> wonder how that is done. I will take a look.
If Python can be compiled as C++, that might be one way.
For proper C, the example below compiles with:
gcc -lstdc++ main.c test_extern_C.cc -o main
‘gcc' is though 'clang' on OS X 10.10.
----
// test_extern_C.cc
#include <string>
#include <cstring>
char str[30];
extern "C" char* hi() {
std::string s("Hello world!\n");
strcpy(str, s.c_str());
return str;
}
----
/* main.c */
#include <stdio.h>
extern char* hi();
int main() {
char* p = hi();
printf(p);
return 0;
}
----