I am learning flatbuffers and I wish to use them in C. What I'm trying to do is writing a schema file for my structs. this is one of my structs:
typedef struct
{
unsigned short request_number;
unsigned short length;
unsigned short height;
unsigned char *buffer;
} CASH_RECEIPT_REQUEST;
How can i write the pointer unsigned char *buffer
in my schema file?
Pointer sizes are platform dependent. If you decide use it on 64-bit processor with 8 bytes size pointers you can use ulong (as schema specifies in here) ulong size is 8 bytes. So at the parsing side you can typecast the ulong (In other words unsigned long) to char* type to obtain the correct pointer value. Sample schema for your example looks like this
CASH_RECEIPT_REQUEST {
request_number:ushort;
length:ushort;
height:ushort;
buffer:ulong;
}