Linked Questions

5 votes
2 answers
7k views

Is the following supposed to be valid for the declaration of table_type, specifically the e[]: struct table_type { unsigned int8 a; unsigned int8 b; unsigned int8 c; unsigned int8 d; ...
BasicPoke's user avatar
1 vote
0 answers
40 views

In a library for binary messaging, I have some structs like these: struct __attribute__((__packed__)) Header { int16_t msg_type; int16_t msg_size; char payload[]; }; struct __attribute__(...
Barry's user avatar
  • 312k
44 votes
4 answers
3k views

I use sizeof to get size of a struct in C, but the result I got is unexpected. struct sdshdr { int len; int free; char buf[]; }; int main(){ printf("struct len:%d\n",(sizeof(struct ...
ssj's user avatar
  • 1,817
17 votes
2 answers
3k views

A struct with a flexible array member, apparently, is not intended to be declared, but rather used in conjunction with a pointer to that struct. When declaring a flexible array member, there must be ...
Theo Chronic's user avatar
  • 1,653
14 votes
1 answer
2k views

In C++11 it allows you to create a 0 length C array and std:array like this: int arr1[0]; std::array arr2<int,0>; So I'm thinking what is the use of a array that doesn't have a space to store? ...
Nayana Adassuriya's user avatar
3 votes
2 answers
1k views

Zero-length arrays are allowed in GNU C. and can be initialized thus struct line { int length; char contents[0]; }; struct line *thisline = (struct line *) malloc (...
krisharav's user avatar
  • 485
0 votes
2 answers
2k views

I am developing a client/server application in C, in which multiple clients send requests through a common FIFO. The data being sent to the server is a struct containing multiple parameters ...
GRoutar's user avatar
  • 1,455
4 votes
2 answers
1k views

How can I combine the variable length struct idiom struct Data { std::size_t size; char data[]; }; with the make_shared idiom which does essentially the same thing so that I can end up with a ...
Michael Marcin's user avatar
1 vote
2 answers
2k views

My struct code is just like this: typedef struct { int w; int h; float m[w][h]; } Matrix; But I'm just getting this errors: "error: 'w' undeclared here (not in a function)" "...
Brian Hardy's user avatar
0 votes
2 answers
2k views

I have a struct that looks like this. struct MyStruct1 { int (*fn)(); int b; } And another struct that looks like this. struct MyStruct2 { int a; struct MyStruct1 b[0]; } I would ...
Jack Maloney's user avatar
0 votes
3 answers
764 views

#include<iostream> #include<string> using namespace std; class LFSR { private: bool lfsr[]; private: int tap; private: int t; private: string s; public: LFSR(string ...
user avatar
0 votes
1 answer
968 views

I am trying to understanding devm_kzalloc() function implementation. It is allocating more than the requested memory(sizeof(struct devres) + size) to manage resources. struct devres is defined as ...
user3693586's user avatar
  • 1,307
2 votes
3 answers
200 views

In this Stackoverflow question or in the article Undefined behavior can result in time travel (among other things, but time travel is the funkiest) one may learn that accessing data structures at ...
18446744073709551615's user avatar
-1 votes
3 answers
208 views

Is there any way to find the structure size dynamically in C?? Sizeof is compile time operator.. so what's the other option. If we can have dynamically allocated array(flexible arrays) in a ...
Siri's user avatar
  • 29
3 votes
1 answer
150 views

In my day job, I have encountered a lot of C codes resembling the following pattern. I am worrying whether this pattern is safe. typedef struct { unsigned char someField : 4; unsigned char ...
user avatar

15 30 50 per page