Complie and link C++ code in C
Hello people,
it's been a long since last time I worked with C and C++. Is it possible to link Cpp code in C?
What I mean is this:
In basics, it comes to this...
I have two files:
Test_cpp.h
Test_cpp.cpp
Code:
int test_cpp(int x)
{
return x+2;
}
and main.c /*in other C project in which Test_cpp.h and Test_cpp.cpp are included*/
Code:
#include <stdio.h>
#include "Test_CPP.h"
int main(int argc, char *argv[])
{
printf("%d", test_cpp(4));
return 0;
}
Is it possible to use extern keyword to make this work?
Thanks