c – 由于LARGEADDRESSAWARE而检测指针算术

我想将我的应用程序切换到LARGEADDRESSAWARE.需要注意的一个问题是指针算术,因为指针差异不能再表示为带符号32b.

有没有办法如何在大型C项目中自动查找指针减法的所有实例?

如果没有,是否有一些“尽力而为”的手动或半自动方法如何实现这一目标?

解决方法

PC-Lint可以找到这种问题.

看看http://gimpel-online.com/MsgRef.html,错误代码947:

Subtract operator applied to pointers — An expression of the form p – q was found where both p and q are pointers. This is of special importance in cases where the maximum pointer can overflow the type that holds pointer differences. For example,suppose that the maximum pointer is 3 Gigabytes -1,and that pointer differences are represented by a long,where the maximum long is 2 Gigabytes -1. Note that both of these quantities fit within a 32 bit word. Then subtracting a small pointer from a very large pointer will produce an apparent negative value in the long representing the pointer difference. Conversely,subtracting a very large pointer from a small pointer can produce a positive quantity.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...