Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

Question list filters

Filter by
Sorted by
Tagged with
Filter by Employee ID
Score of 0
1 answer
118 views

In drone.h, I have a struct typedef struct { char name[MAX_DRONE_NAME_LENGTH]; enum drone_model model; uint8_t status_bitarr; } drone; and a define #define DRONE_STATUS_LENGTH (8*sizeof( ((...
Score of -1
1 answer
297 views

I had an idea to add texts for string but don't know how to calculate it for unsigned char*. Is the size for const char* the same as const unsigned char*? const std::string s = "...."; const ...
Score of -1
3 answers
137 views

Given the following C struct: struct __attribute__((__packed__)) XIRControl { uint8_t command; char code[19]; uint16_t error; union codeData { struct rcvCommands { ...
Score of 15
4 answers
1258 views

Unlike C array, std::array is allowed to have zero length. But the current implementations differ in how std::array<T,0> is implemented, in particular the sizes of the object are different. This ...
Score of 0
3 answers
297 views

When the array type is a "void *", then it can be allocated by: void **void_array; void_array = malloc(sizeof(void*) * 1); But, if the array type is a struct Hello *, then what should be ...
Score of 3
4 answers
395 views

Say, is sizeof(void*) the same as the size processor can atomically access per instruction? For example, 32-bit processor can read aligned 4 bytes atomically, 64-bit processor can read aligned 8 bytes ...
Score of 0
1 answer
123 views

This does not answer my need. I do not want to generate an error, I want to adapt the behavior of the software depending on the condition. Example: #if ( sizeof(unsigned long) == 4 ) # define a 5 #...
Score of 1
1 answer
346 views

I did a static_assert to make sure that a valid type was used. I don't know if I just should have checked if the type is void, or whether any type can have size zero (I think it can with [[...
Score of 3
1 answer
159 views

I want to create a function like SizeOf() of C++ for powershell, but apparently Microsoft uses some strange algorithm/formula to determine the mebibytes. Example: If you create file with exactly 1.856....
Score of 2
4 answers
251 views

Consider this example where I add some extra \0 to a string. #include <stdio.h> #include <string.h> int main(int argc, char **argv){ char str1[] = "dog"; char str2[] = &...
Score of 3
2 answers
222 views

I've got a question regarding the sizeof() operator. Browsing Open Source projects written in C obviously, some developers tend to use the sizeof() operator in one place and on other places the ...
Score of -6
1 answer
205 views

There is one huge struct in our code, and its being passed around everywhere as a value. I would like to be able to know the size(amount of memory in bytes, go will allocate for a variable of this ...
Score of 4
5 answers
283 views

I have an array of color codes, the size of which is known at compile time. I want to declare another array of the same size. But the code below throws an error. I can, of course, declare the size ...
Score of 3
1 answer
176 views

Suppose we have the source: #include <stdint.h> #include <stdio.h> struct foo { char b ; char a [ SIZE_MAX ] ; } ; int main ( void ) { const size_t z = sizeof ( struct foo ) ; ...
Score of 2
0 answers
126 views

Does the C++ standard have anything to say about the size equality of the following? struct AB { int a; int b; } Or struct A { int a }; struct B : public A { int b; } Is sizeof(...

15 30 50 per page
1
2 3 4 5
144