All Questions
6 questions
-1
votes
1
answer
433
views
Strange behavior of #pragma pack
I am facing a strange issue when using #pragma pack.
I have the following structs:
st_a: packed with #pragma pack(1). Size = 1 byte. Contains bitfields.
st_b: packed with #pragma pack(2). Size = 14 ...
0
votes
0
answers
40
views
how to control padding between struct elements in GNU compiler? [duplicate]
In below code. When I print individual char array size it prints correct value.
But when I print whole struct size at a time it adds one byte more for each char array.
How can I control padding ...
5
votes
4
answers
4k
views
Packing bools with bit field (C++)
I'm trying to interface with Ada code using C++, so I'm defining a struct using bit fields, so that all the data is in the same place in both languages. The following is not precisely what I'm doing, ...
2
votes
1
answer
7k
views
Alignment of struct didn't work with #pragma pack
I have a c++ structure:
struct a
{
char b;
int c;
int d[100];
};
The size of the struct should be 405 bytes.
I saw that the size of the struct is 408 bytes. The reason is the ...
1
vote
1
answer
281
views
c++ wrong values with pragma pack
header1.h
#pragma pack(4)
header2.h
#include <iostream>
struct my_struct
{
unsigned int a;
double b;
};
__forceinline void show_h(my_struct* my_struct_ptr)
{
std::cout << sizeof(...
4
votes
1
answer
699
views
Struct packing in GCC on 32-bit doesn't work?
I have inherited some third-party code in a project. It's comprised of a header file and a binary library without sources, so I cannot just recompile it with different settings.
The header uses a ...