A
abasili
Hi everyone, I'm trying to compile a C++ function and then call it from
a C program.
Since Google is my friend I've ended up to this link which seems very clear:
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html
Unfortunately it does not work.
Here is what I'm doing:
-----------------------------------------
//main.c
#include "mylib.h"
int main (int argc, char *argv[]){
foo();
return 0;
}
-----------------------------------------
//mylib.h
#indef __cplusplus
extern "C"{
#endif
void foo();
#ifdef __cplusplus
}
#endif
-----------------------------------------
//mylib.cc
#include <iostream>
#include "mylib.h"
using namespace std; // don't know what for!
void foo(){
cout<<"Hello World!\n";
}
-----------------------------------------
Thanks a lot for any suggestion.
Al
a C program.
Since Google is my friend I've ended up to this link which seems very clear:
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html
Unfortunately it does not work.
Here is what I'm doing:
-----------------------------------------
//main.c
#include "mylib.h"
int main (int argc, char *argv[]){
foo();
return 0;
}
-----------------------------------------
//mylib.h
#indef __cplusplus
extern "C"{
#endif
void foo();
#ifdef __cplusplus
}
#endif
-----------------------------------------
//mylib.cc
#include <iostream>
#include "mylib.h"
using namespace std; // don't know what for!
void foo(){
cout<<"Hello World!\n";
}
-----------------------------------------
Thanks a lot for any suggestion.
Al