国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

Macro Definitions of Functions

2019-11-17 05:39:45
字體:
供稿:網(wǎng)友

  If we describe something as a function in this manual, it may have a macro definition as well. This normally has no effect on how your PRogram runs--the macro definition does the same thing as the function would. In particular, macro equivalents for library functions evaluate arguments exactly once, in the same way that a function call would. The main reason for these macro definitions is that sometimes they can prodUCe an inline eXPansion that is considerably faster than an actual function call.

Taking the address of a library function works even if it is also defined as a macro. This is because, in this context, the name of the function isn't followed by the left parenthesis that is syntactically necessary to recognize a macro call.

You might occasionally want to avoid using the macro definition of a function--perhaps to make your program easier to debug. There are two ways you can do this:

You can avoid a macro definition in a specific use by enclosing the name of the function in parentheses. This works because the name of the function doesn't appear in a syntactic context where it is recognizable as a macro call.
You can suppress any macro definition for a whole source file by using the `#undef' preprocessor directive, unless otherwise stated explicitly in the description of that facility.
For example, suppose the header file `stdlib.h' declares a function named abs with

extern int abs (int);

and also provides a macro definition for abs. Then, in:

#include <stdlib.h>
int f (int *i) { return (abs (++*i)); }

the reference to abs might refer to either a macro or a function. On the other hand, in each of the following examples the reference is to a function and not a macro.

#include <stdlib.h>
int g (int *i) { return ((abs)(++*i)); }

#undef abs
int h (int *i) { return (abs (++*i)); }

Since macro definitions that double for a function behave in exactly the same way as the actual function version, there is usually no need for any of these methods. In fact, removing macro definitions usually just makes your program slower.

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 安吉县| 璧山县| 满洲里市| 湾仔区| 静乐县| 新乐市| 广西| 博罗县| 辉南县| 会东县| 衡水市| 长汀县| 株洲县| 云浮市| 谷城县| 凤城市| 平谷区| 哈密市| 浮梁县| 策勒县| 从化市| 泌阳县| 淮北市| 临沭县| 黑河市| 射洪县| 望奎县| 双牌县| 尼勒克县| 山丹县| 横峰县| 保定市| 桂东县| 灌阳县| 富宁县| 资兴市| 太和县| 香格里拉县| 芜湖市| 独山县| 鄂托克前旗|