Can you show some relevant code ?
Simple code using function defined in .c file in .cpp file:
// cfunc.h
#ifndef _FUNC_H_
#define _FUNC_H_
void func();
#endif
// cfunc.h
#ifndef _FUNC_H_
#define _FUNC_H_
void func();
#endif
To copy to clipboard, switch view to plain text mode
// cfunc.c
#include <stdio.h>
#include "cfunc.h"
void func(){
printf("works?\n");
}
// cfunc.c
#include <stdio.h>
#include "cfunc.h"
void func(){
printf("works?\n");
}
To copy to clipboard, switch view to plain text mode
// main.cpp
extern "C"{
#include "cfunc.h"
}
int main(){
func();
return 0;
}
// main.cpp
extern "C"{
#include "cfunc.h"
}
int main(){
func();
return 0;
}
To copy to clipboard, switch view to plain text mode
Compile & run:
gcc -c cfunc.c
g++ main.cpp cfunc.o -o main.exe
main.exe // prints works ?
Bookmarks