Skip to content

Commit 273a44d

Browse files
committed
This code tests to see that the CBE will execute data-packing in a structure correctly.
Previous code was related to Bit Fields. I have written a new test case to demonstrate Data-Packing in C.
1 parent a3ae78a commit 273a44d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

test/test089.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@
1111
// *TW
1212
//===------------------------------------------------------------------------------===//
1313

14-
struct packed_test {
15-
unsigned int var1:4;
16-
unsigned int var2:4;
17-
unsigned int var3:4;
14+
#pragma pack(push)
15+
#pragma pack(1)
16+
17+
struct DataSize{
18+
char Data2;
19+
char Data3;
20+
int Data1;
1821
};
1922

2023
int main(){
21-
struct packed_test variable;
22-
variable.var2 = 5;
23-
variable.var3 = 6;
24-
variable.var1 = 9;
25-
26-
return variable.var3;
24+
struct DataSize example;
25+
return sizeof(example);
2726
}
28-

0 commit comments

Comments
 (0)