I'm trying to use C-sourced functions in my C++ code. And I have some difficulties, when I try to instantiate in my C++ code structure which is declared in C-header, and then transfer it to C-function by value. Example:
dummyc.h:
#ifndef _DUMMY_C_H_
#define _DUMMY_C_H_
typedef struct {
int a;
int b;
int c;
int d;
}DUMMYS;
int dummyFunction(unsigned int a, unsigned int b, unsigned short c, DUMMYS dummy);
#endif
dummyc.c:
#include "dummyc.h"
int dummyFunction(unsigned int a, unsigned int b, unsigned short c, DUMMYS dummy){
return 1;
}
dummycpp.cpp:
extern "C"{
#include "dummyc.h"
}
int main(){
DUMMYS s = {0,0,0,0};
return dummyFunction(50,50,1,s);
}
During dummyFunction execution I see that data on stack is incorrect. It seems like they where shifted?? How I can do this correctly??? Im using GCC 4.3.4 for ARM.