So I want to do this
in main static OBD_device *device; device = getDevice(); device->init();
in h
typedef struct { void (*init)(void); char (*probeForGW)(void); char (*getData)(void); char (*setData)(void); char (*writeBack)(void); char (*reset)(void); } OBD_device;
in C class
OBD_device *getDevice(void);
. . functions.. .
OBD_device Device = { .init = Init, .probeForGW = ProbeForGW, .getData = GetData, .setData = SetData, .writeBack = WriteBack, .reset = Reset, };
OBD_device *getDevice(void) { return &Device; }
This does not working in some version of C, is c99 one of them? Is there any way to use a newer version of c with Keil IDE?
I was able to make it work,. I had to define a extern OBD_device *getDevice(void);
previously in other projects I didnt have to.