I need to access the content of a struct, defined in the header of a c file within in a c++ file.
The header-file struct.h
has currently following format:
typedef struct {
int x;
int y;
} structTypeName;
extern structTypeName structName;
The struct is used and modified in the file A.c
#include "struct.h"
structTypeName structName;
int main(){
structName.x = xyz;
structName.y = zyx;
}
I now need to access the struct in a c++ file B.cpp
(yes, it has to be c++). I've tried out a bunch of different ideas, but nothing has worked out so far. Can somebody please give me an idea how to realize this?
EDIT:
The c++ file looks following atm:
#include <iostream>
extern "C"{
#include "struct.h"
}
int main(){
while(true){
std::cout << structName.x << "\n";
}
}