hi, 

thanks all, but can some1 sum it up in a more 'noobish' way? :D

im using GCC 4.0 as compiler, under OS X using IDE XCode. The compiler is 
integrated. 

so here is what im doin: im trying to write a tga file and the struct is the 
header of the image (contains width, height, alpha etc). and yes im using the 
struct to keep header properties and write it at once:

fwrite(&header, sizeof(TGAHeader), 1, fp);

my question is what is this pragma code do? how it can affect my writing file?


Thanks in advance :)
 
--- On Mon, 1/5/09, Paul Herring <[email protected]> wrote:

> From: Paul Herring <[email protected]>
> Subject: Re: [c-prog] #pragma definition?
> To: [email protected]
> Date: Monday, January 5, 2009, 10:11 PM
> On Tue, Jan 6, 2009 at 12:07 AM, Jos Timanta Tarigan
> <[email protected]> wrote:
> > Hi,
> >
> > i notice this line:
> >
> > #pragma pack(push,1)
> > struct TGAHeader {
> >
> > bla bla bla...
> >
> > };
> > #pragma pack(pop)
> >
> > what is the definition of pragma exatly?
> 
> It's for compiler specific features. From the context
> (it's using
> something called pack(), and it's containing a struct
> definition) at a
> guess it removes all struct padding.
> 
> > i use this struct as a header that will be written in
> a file. when i delete this line, the file can
> >  not be opened by the application (corrupted). can
> any1 help me?
> 
> Removing the pragma will result in struct padding being
> reinstated,
> resulting in the struct taking up more memory.
> 
> I'm guessing that the program writes the struct to file
> in one go (as
> opposed to member by member.)
> 
> 
> -- 
> PJH
> 
> http://shabbleland.myminicity.com


      

Reply via email to