This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

c99 compiler can support class pointers

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?

Parents Reply Children
No data