NickThePowerful / iphone-dev

Automatically exported from code.google.com/p/iphone-dev
0 stars 0 forks source link

#pragma pack(1) BUG #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

#pragma pack(1)
typedef struct{
  unsigned short a
} A;

int main()
{       
    printf("%d",sizeof(A));
}

What is the expected output? What do you see instead?
Expect to get "2", but see "4" instead.

What version of the product are you using? On what operating system?
Revision: 172 - 174 (earlier revisions not tested yet)

MacOS X 10.4.10

Please provide any additional information below.

Original issue reported on code.google.com by flyl...@gmail.com on 21 Sep 2007 at 8:49

GoogleCodeExporter commented 9 years ago
Have you tried __attribute__((packed))? #pragma pack is the Microsoft way of 
doing things and while GCC may 
support it I'm not sure if LLVM-GCC does.

Original comment by nightwat...@gmail.com on 23 Sep 2007 at 8:44

GoogleCodeExporter commented 9 years ago
Actually, you may be misunderstanding packed structures. I'm not certain that 
pack prohibits structures from 
being rounded up to a certain value - it only prohibits space from being 
inserted in between members.

Original comment by nightwat...@gmail.com on 23 Sep 2007 at 9:08

GoogleCodeExporter commented 9 years ago
It was (pre-2.1) llvm-gcc bug not to handle 'pack' pragma. However, bug was for
non-darwin hosts only. You might want to check llvm-gcc TOT (or at least 2.1
release). Please fill LLVM bug if it will still fail for you.

PS: "2" is correct answer here.

Original comment by korobeyn...@gmail.com on 10 Oct 2007 at 1:50