Meaning of Packed and Local types

M

Muralidhar

Hi all,

I saw in one function that its return type was written as PACKED...I wasnt
sure what that would mean. Any pointers on this?

Also, what is the significance of specifically mentioning the LOCAL to a
function definition when it will be a local function without the access of
its declaration?

Thanks
Murali
 
E

Eric Sosman

Muralidhar said:
Hi all,

I saw in one function that its return type was written as PACKED...I wasnt
sure what that would mean. Any pointers on this?

Also, what is the significance of specifically mentioning the LOCAL to a
function definition when it will be a local function without the access of
its declaration?

Neither PACKED nor LOCAL has any meaning in "out of
the box" C. They are probably #define'd as macros that
expand to something meaningful, possibly compiler-specific.
 
C

Christian Staudenmayer

Eric Sosman is right, this isn't part of the Standard. However, if you
were wondering what "Packed" means, it usually describes a way to store
several values in one variable. For example, you might have a program
that needs millions of "boolean" values (0 or 1). Using char for that
would be a waste of 7/8th of the memory. You could now write a function
that "packs" 8 boolean values into one char (since char is guaranteed to
be at least 8 bit wide).

Greetings, Chris
 
T

Trent Buck

To follow up on what others have said, packed is a variable attribute
provided by the GCC[0] as an extension. This is documented in the
(tex)info manual, which if installed can be accessed via the command:

info gcc 'C Extensions' 'Variable Attributes'

-trent

[0] And possibly others, I don't know.
 
B

Ben Pfaff

Trent Buck said:
To follow up on what others have said, packed is a variable attribute
provided by the GCC[0] as an extension.

But it isn't written PACKED. There is probably macro trickery
going on here.
 
M

Muralidhar

Yup...the GCC reference for that was __packed.

I guess it must be a typedef since the compiler/linker has to know when to
pack ...am I right?

murali
Ben Pfaff said:
Trent Buck said:
To follow up on what others have said, packed is a variable attribute
provided by the GCC[0] as an extension.

But it isn't written PACKED. There is probably macro trickery
going on here.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p\
);}return 0;}
 
P

pete

Muralidhar said:
Yup...the GCC reference for that was __packed.

I guess it must be a typedef since the compiler/linker
has to know when to pack ...am I right?

I'm guessing that it's a macro defined somewhere in the source code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top