声明:
1、本翻译仅供个人学习使用,本人没有提供技术支持的义务,也不承担由此引发的任何后果。
2、请勿用于商业用途。
3、英文来自:http://www.keil.com/support/man/docs/c51/。
4、欢迎大家共同与我交流探讨(290207203@qq.com)。
INTPROMOTE Compiler Directive
Abbreviation | IP | ||||||||
Arguments | None. | ||||||||
Default | INTPROMOTE | ||||||||
µVision | Options — C51 — Enable ANSI integer promotion rules. | ||||||||
Description | The INTPROMOTE directive enables ANSI integer promotion rules. Expressions used in if statements are promoted from smaller types to integer expressions before comparison. This allows Microsoft C and Borland C programs to be ported to the C51 Compiler with fewer modifications. Since the 8051 is an 8-bit processor use of the INTPROMOTE directive may generate less efficient code in some applications. | ||||||||
See Also | |||||||||
Example | C51 SAMPLE.C INTPROMOTE #pragma intpromote C51 SAMPLE.C NOINTPROMOTE The following example: stmt lvl source 1 char c; 2 unsigned char c1,c2; 3 int i; 4 5 main () { 6 1 if (c == 0xff) c = 0; /* never true! */ 7 1 if (c == -1) c = 1; /* works */ 8 1 i = c + 5; 9 1 if (c1 < c2 +4) c1 = 0; 10 1 } demonstrates code generated using both the INTPROMOTE and NOINTPROMOTE control directives.
|
INTPROMOTE 编译器伪指令
缩写 | IP | ||||||||
参数 | 无。 | ||||||||
缺省 | INTPROMOTE | ||||||||
µVision | Options — C51 — Enable ANSI integer promotion rules. | ||||||||
描述 | INTPROMOTE伪指令使能ANSI 整型提升规则。在编译之前,if语句中声明的表达式从更小的类型提升到整型表达式。这样,只需要少量的修改,就可以把 Microsoft C 和 Borland C 程序移植到 C51 编译器。 因为8051是一个8位处理器,在一些应用程序中,使用INTPROMOTE 伪指令可能生成不是很高效的代码。 | ||||||||
参考 | |||||||||
示例 | C51 SAMPLE.C INTPROMOTE #pragma intpromote C51 SAMPLE.C NOINTPROMOTE 下面的示例: stmt lvl source 1 char c; 2 unsigned char c1,c2; 3 int i; 4 5 main () { 6 1 if (c == 0xff) c = 0; /* never true! */ 7 1 if (c == -1) c = 1; /* works */ 8 1 i = c + 5; 9 1 if (c1 < c2 +4) c1 = 0; 10 1 } 展示使用INTPROMOTE 和 NOINTPROMOTE 伪指令生成的代码。
|