[2.2] Cant get __attribute__ ((__packed__)) to work
[2.2] Cant get __attribute__ ((__packed__)) to work
- Subject: [2.2] Cant get __attribute__ ((__packed__)) to work
- From: Dave Camp <email@hidden>
- Date: Mon, 14 Nov 2005 17:50:34 -0800
I'm updating some old code that was last built with Project Builder
and gcc 2.95. I've got some enums that need to be 1 byte, not an int
(the typedefs are used in structs that are sent to a device over USB).
The following code shows all the permutations I've tried... I'm
assuming I can't use -fshort-enums, since that would mess up enum
sizes from the frameworks and whatnot.
Any thoughts? From what I've read in the gcc 4 docs, it looks like
one of the first three should have worked, but I get the following
errors:
main.cpp:9: warning: '__packed__' attribute ignored
main.cpp:34: error: non-local function 'fooEnum
whatever::GetCart1LogID()' uses anonymous type
main.cpp:9: error: 'typedef enum<anonymous> fooEnum' does not refer
to the unqualified type, so it is not used for linkage
Thanks,
Dave
#include <CoreFoundation/CoreFoundation.h>
//
------------------------------------------------------------------------
--------
// Generates an error
//typedef enum
//{
// foo = 0x10
//} fooEnum __attribute__ ((__packed__));
// Generates an error
//typedef enum __attribute__ ((__packed__))
//{
// foo = 0x10
//} fooEnum;
// Generates an error
//typedef __attribute__ ((__packed__)) enum
//{
// foo = 0x10
//} fooEnum;
// Works, but enum is too big...
typedef enum
{
foo = 0x10
} fooEnum;
//
------------------------------------------------------------------------
--------
class whatever
{
public:
fooEnum SomeMethod(void) const;
};
//
------------------------------------------------------------------------
--------
int main (int argc, const char * argv[])
{
printf("size = %d", sizeof(fooEnum));
return 0;
}
---
There's an old proverb that says just about whatever you want it to.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden