Hi, There's two things going on here. 1. INT32U is being used as a short-hand for "unsigned int". There are two reasons I can think for defining this: (a) its quicker and simpler to write and, more importantly, (b) if the definition is in an include file, the file can be constructed or altered to suit different platforms. Thus on some platforms INT32U might be defined as "unsigned long int". Done this way, the main body of code doesn't have to change: if you want an unsigned 32-bit integer, you just use the defined type "INT32U". By the way, using upper case as a type name is a somewhat old practice (derived from using MACROs to define types before "typedef" was part of the langaue). 2. The construct "(*(INT32U *) VALUE)" is a very common way of enabling a constant integer value to be used as an address (i.e. pointer) type. The "(INT32U *) VALUE" part says "treat VALUE as a "pointer to an unsigned int". The extra "*" then says de-reference this pointer. It lets you write code like: BSP_UNDEF_INSTRUCTION_VECTOR_ADDR = 0; This stores the value 0 at the address 0x00000004. A variation on this is to define a MACRO such as: #define REG(addr) (*(volatile unsigned int *)(addr)) You can use this like: #define VICIntEnable (0xFFFFF010) REG(VICIntEnable) = 0x40; Brendan --- In lpc2000@yahoogroups.com, jk jlkj <njad2002@...> wrote: > > Hi Friends, > > Did anyone came accross such a code. > > INT32U is unsigned int. > > #define BSP_UNDEF_INSTRUCTION_VECTOR_ADDR (*(INT32U *) 0x00000004L) > > I really think this is a neat code. This is in the code given by ucos-ii. > Isnt this similar to declaring a pointer variable. > > I am unable to understand the meaning of the type cast (*(INT32U *)) > > Can some one please tell me what does this type cast imply. > > Regards, > Jerome > > > > > --------------------------------- > Yahoo! India Answers: Share what you know. Learn something new. Click here > > [Non-text portions of this message have been removed] >
Message
Re: Good C code
2006-05-05 by brendanmurphy37
Attachments
- No local attachments were found for this message.