lkml.org 
[lkml]   [2001]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectsizeof problem in kernel modules
Date

Hi !

can someone explain to me whats happening here ?

--simple.c--
#include <linux/module.h>
#include <linux/kernel.h>

struct { short x; long y; short z; }bad_struct;
struct { long y; short x; short z; }good_struct;
int init_module(void){
printk("good_struct %d, bad_struct %d\n",sizeof(good_struct),sizeof(bad_struct));
return 0;
}
void cleanup_module(void){
}
--Makefile--

all: simple.o

CC= gcc
CFLAGS= -pipe -fno-strength-reduce -DCPU=686 -march=i686 \
-Wall -Wstrict-prototypes -g -D__KERNEL__ -DMODULE \
-D_LOOSE_KERNEL_NAMES -O2 -c
INCLUDE= -I/usr/include/linux

clean:
rm -f simple.o

---------------------------------------------------------------
I would expect both structs to be 8byte in size , or atleast the same size !
but good_struct turns out to be 8bytes and bad_struct 12 .

what am I doing wrong here ?

thx !
hofrat
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:55    [from the cache]
©2003-2011 Jasper Spaans