请问在函数前加宏是什么意思.

lf2hl 2008-11-17 09:21:10
#define AAA BBB
AAA string* funN()
{
....
}

在函数前加宏是什么意思.
...全文
793 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
deerwin1986 2008-11-18
  • 打赏
  • 举报
回复
函数调用方式 或者CALLBACK之类
就呆在云上 2008-11-18
  • 打赏
  • 举报
回复
一般情况下,没有什么意思纯粹就是给自己看看,或者说就是自己研究下
比如:
#define __wori 

int __wori func1() {
return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
func1();
return 0;
}


不过系统里面的几个东西还是有特定作用的,比如__stdcall和__cdecl
可以查看以下msdn
hzc191025 2008-11-18
  • 打赏
  • 举报
回复
函数调用协议
nullah 2008-11-18
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyu637 的回复:]
一般是定义函数的编译类型,

比如有的DLL的导出头文件,或者表明这个函数的与c兼容之类的。
[/Quote]
UP
ForestDB 2008-11-18
  • 打赏
  • 举报
回复 1
要么是类型,要么是调用惯例,要么是些说明性质的宏(这些没有宏体,替换后是空,可以起到解释说明的作用)。
具体情况具体分析。
lgccaa 2008-11-18
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 zmlovelx 的回复:]
应该是calling conventions
The following calling conventions are supported by the Visual C/C++ compiler.

Keyword Stack cleanup Parameter passing
__cdecl
Caller
Pushes parameters on the stack, in reverse order (right to left)

__clrcall
n/a
Load parameters onto CLR expression stack in order (left to right).

__stdcall
Callee
Pushes parameters on the stack, in reverse o…
[/Quote]

UP
qqwx_1986 2008-11-18
  • 打赏
  • 举报
回复
貌似主要是与c兼容的多
mimong_lin 2008-11-18
  • 打赏
  • 举报
回复
宏只是一个替代,你把替代的东西还原到代码中,就知道是什么作用了。
cyj626 2008-11-18
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 zmlovelx 的回复:]
引用 6 楼 arong1234 的回复:
楼主说的不是这种宏,他指得是诸如CALLBACK/WINAPI之类增加可读性、可维护性得宏
引用 5 楼 elmnd 的回复:
加那些#ifdef的貌似是用于防止重定义的吧?

up
[/Quote]
up
学习
zhoulb_ndsc 2008-11-18
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyu637 的回复:]
一般是定义函数的编译类型,

比如有的DLL的导出头文件,或者表明这个函数的与c兼容之类的。
[/Quote]
学习.
帅得不敢出门 2008-11-18
  • 打赏
  • 举报
回复
应该是calling conventions
The following calling conventions are supported by the Visual C/C++ compiler.

Keyword Stack cleanup Parameter passing
__cdecl
Caller
Pushes parameters on the stack, in reverse order (right to left)

__clrcall
n/a
Load parameters onto CLR expression stack in order (left to right).

__stdcall
Callee
Pushes parameters on the stack, in reverse order (right to left)

__fastcall
Callee
Stored in registers, then pushed on stack

__thiscall
Callee
Pushed on stack; this pointer stored in ECX


Calling convention for callback functions.
This type is declared in WinDef.h as follows:
#define CALLBACK __stdcall


帅得不敢出门 2008-11-18
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 arong1234 的回复:]
楼主说的不是这种宏,他指得是诸如CALLBACK/WINAPI之类增加可读性、可维护性得宏
引用 5 楼 elmnd 的回复:
加那些#ifdef的貌似是用于防止重定义的吧?
[/Quote]
up
太乙 2008-11-18
  • 打赏
  • 举报
回复
要不lz贴一个示例程序看看~~~
Longinc 2008-11-18
  • 打赏
  • 举报
回复
BBB 就代表 AAA
hznat 2008-11-18
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 toadzw 的回复:]
在函数前边表示函数的返回类型;
[/Quote]

AAA string* funN()

string* 才是返回类型
phisherr 2008-11-18
  • 打赏
  • 举报
回复
很多时候会有一些替换为空的宏,无非两个作用
1、解释作用,相当于注释
2、做占位用,便于以后扩展
toadzw 2008-11-17
  • 打赏
  • 举报
回复
在函数前边表示函数的返回类型;
toadzw 2008-11-17
  • 打赏
  • 举报
回复
其是代表的意义:AAA将直接在程序中表示BBB;
arong1234 2008-11-17
  • 打赏
  • 举报
回复
楼主说的不是这种宏,他指得是诸如CALLBACK/WINAPI之类增加可读性、可维护性得宏
[Quote=引用 5 楼 elmnd 的回复:]
加那些#ifdef的貌似是用于防止重定义的吧?
[/Quote]
elmnd 2008-11-17
  • 打赏
  • 举报
回复
加那些#ifdef的貌似是用于防止重定义的吧?
加载更多回复(4)

64,643

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧