I am trying to initialize a struct
in its constructor but I run into a compiler error on the last line when I am initializing the member header.length
. Is its size known at the time?
This is the compiler error and the structure
:
In constructor ‘stDescriptor::stDescriptor()’:
error: expected primary-expression before ‘)’ token
struct stDescriptor {
usb_functionfs_descs_head header;
stDescriptorBody fs_descs;
stDescriptorBody hs_descs;
stDescriptor(){
header.fs_count = 3;
header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC);
header.hs_count = 3;
header.length = cpu_to_le32(sizeof stDescriptor);
}
};