[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Skum struct.



Heini Reinert wrote:
> 
> Anders Melchiorsen wrote:
> 
> > Carsten Nissen <sslug@sslug> skrev:
> >
> > > >Nej!!! En int er ikke defineret til at være noget som helst, udover at
> > >
> > > Siger man ikke at en int, på samme "størrelse" som maskinen, fx.:
> > >
> > > 16 bit(286) - 32 bit(386) - 64 bit(alpha)
> >
> > Det er tommelfingerreglen, jo - men når du skriver portabelt ved du
> > ikke, hvilken maskine, du er på. Amiga compilere havde fx en switch
> > til at skifte størrelsen, husker jeg.
> >
> > Men int regnes vist som den heltallige type, hvor maskinen regner
> > bedst.
> > --
> > Regards, Anders                         If a Microsoft product
> > (address is valid)                      fails, who do you sue?
> 
> Hej med jer.
> 
> En int = integer = heltal
> Den fylder 2 byte = 16 bit
> 
> float = floating point = kommatal
> Den fylder 4 byte = 32 bit
> 
> Dette gør sig gældende i c++ i hvert fald.

Som jeg skrev tidligere er dette ikke tilfældet i C. 

Jeg ved ikke om den oprindelige spørger har fået løst sit problem,
ellers kommer den her:

brug __atribute__ ((packed)) efter elementer i strukturen som det fx.
ses i /usr/include/linux/ncp.h:

struct nw_search_sequence {
        __u8 volNumber __attribute__((packed));
        __u32 dirBase __attribute__((packed));
        __u32 sequence __attribute__((packed));
..
..

Hvis du vil sikre dig at størrelserne er rigtige skal du ikke bruge
{short|int|long) men istedet nogle af de specifikke størrelser. __u8
osv. er kun til kernebrug, de almindelige kan findes i sys/types.h

Mvh Morten


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *