[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] wrong/incorrect result of sizeof

From: ibrahim
Subject: Re: [Tinycc-devel] wrong/incorrect result of sizeof
Date: Tue, 18 Jun 2013 10:06:19 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 18.06.2013 09:24, Ariset Llerena wrote:
the following code

#include <stdint.h>
#include <stdio.h>
struct foobar{
    uint16_t foo; // 4 bytes
    uint64_t bar; // 8 bytes
int main(){
    printf("%d\n", sizeof(struct foobar));
    return 0;

You can change the padding by using

#pragma pack (x)

x=1 : without padding
x=2 : padd for word boundaries
x=4 : padd for dword boundaries
x=8 : padd for qword boundaries
if you use #pragma pack () the system default defined by compiler configurations is used

at least on gcc vc++ ... didn't try for tcc

reply via email to

[Prev in Thread] Current Thread [Next in Thread]