long long alignment in structure for GCC 7.2.0 on Windows

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

 



Hi,
	I'm using "g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.2.0" to compile the following code ("gcc test.c"):
typedef __signed__ char __s8;
typedef unsigned char __u8;

typedef __signed__ short __s16;
typedef unsigned short __u16;

typedef __signed__ int __s32;
typedef unsigned int __u32;

#ifdef __GNUC__
__extension__ typedef __signed__ long long __s64;
__extension__ typedef unsigned long long __u64;
#else
typedef __signed__ long long  __s64;
typedef unsigned long long  __u64;
#endif

typedef		__u8		u_int8_t;
typedef		__s8		int8_t;
typedef		__u16		u_int16_t;
typedef		__s16		int16_t;
typedef		__u32		u_int32_t;
typedef		__s32		int32_t;
typedef		__u64		u_int64_t;

#define __bitwise

typedef __u16 __bitwise __le16;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __le32;
typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __le64;
typedef __u64 __bitwise __be64;

struct f2fs_super_block {
	__le32 magic;			/* 0, Magic Number */
	__le16 major_ver;		/* 4, Major Version */
	__le16 minor_ver;		/* 6, Minor Version */
	__le32 log_sectorsize;		/* 8,log2 sector size in bytes */
	__le32 log_sectors_per_block;	/* 12, log2 # of sectors per block */
	__le32 log_blocksize;		/* 16, log2 block size in bytes */
	__le32 log_blocks_per_seg;	/* 20, log2 # of blocks per segment */
	__le32 segs_per_sec;		/* 24, # of segments per section */
	__le32 secs_per_zone;		/* 28, # of sections per zone */
	__le32 checksum_offset;		/* 32, checksum offset inside super block */
	__le64 block_count;			/* 36, total # of user blocks */
} __attribute__((packed)) ;

#include <stdio.h>

int main(void)
{
	printf("%p", &((struct f2fs_super_block *)0)->block_count);
	return 0;
}

It prints 0000000000000028 on Windows instead of 0000000000000024 on Linux, it seems weird for the packed struct.
And I compile the same code with clang on windows ("clang -target x86_64-pc-windows-gnu test.c"), it prints 0000000000000024.

I have no idea what happened, Could someone give some hints?

Thanks,

Gao Xiang





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux