|
[DPRG] I didn't want this to work: C structure confusion
Subject: [DPRG] I didn't want this to work: C structure confusion
From: Ed Okerson
ed at okerson.com
Date: Fri Sep 8 15:22:47 CDT 2006
Dale,
> volatile struct PINSEL0_T {
> PCB0_0 p0_0 : 2;
> PCB0_1 P0_1 : 2;
> } *PINSEL0 = (struct PINSEL0_T *) 0xE002C000;
The allowed types for bitfields in a struct or union in C are only int,
signed int or unsigned int. What is happening here is the compiler
preprocessor is using the default promotion of your defined types to int,
after that assignment from any other type with the same default promotion
will work without generating any warnings or errors.
Ed
More information about the DPRG mailing list
|