分类: LINUX
2016-10-23 21:33:45
http://blog.csdn.net/phenix_yw2/article/details/5961350
Slade Maurer
Mon Jan 3 17:44:46 GMT 2005
Let's keep in mind that we are discussing header files specifically. __ASSEMBLY__ allows them to be shared between C and assembly code so all the useful data is in the same place -- as Ho Lee said. The CPP does process typedef and #defines as Rainer Weikusat states. However, __ASSEMBLY__ is still required to solve problems with symbols that gas can't understand but cc1 can. For example, this section of code from a header file uses it to solve a problem: #ifdef __ASSEMBLY__ #define __PAGE_OFFSET (0xB0000000) #else #define __PAGE_OFFSET (0xB0000000UL) #endif /* __ASSEMBLY__ */ Now, what is it doing? Well, cleary the developer thought gas would choke on casting the constant as an unsigned long for cc1 and so uses the __ASSEMBLY__ directive to allow __PAGE_OFFSET to be handled by gas and by cc1. More precisely, CPP would use __ASSEMBLY__ to pick the correct __PAGE_OFFSET token. Then, it would substitute occurances in the file(s) it is pre-processing before they are passed to the assembler or compiler. The assembler sees 0xB0000000 and the C compiler sees 0xB0000000UL so they are both happy! Hope this helps. -Slade