Chinaunix首页 | 论坛 | 博客
  • 博客访问: 250045
  • 博文数量: 88
  • 博客积分: 1429
  • 博客等级:
  • 技术积分: 523
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-18 15:31
文章分类

全部博文(88)

文章存档

2017年(2)

2016年(24)

2013年(1)

2012年(24)

2011年(15)

2010年(22)

我的朋友

分类: 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

 

  • Previous message: 
  • Next message: 
  • Messages sorted by:    

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

阅读(377) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~