这样的typedef是什么意思?

hp_oracle 2003-02-26 12:10:12
typedef CMC_return_code (FAR PASCAL *LPFNCMCLOGON)(
CMC_string service,
CMC_string user,
CMC_string password,
CMC_enum character_set,
CMC_ui_id ui_id,
CMC_uint16 caller_cmc_version,
CMC_flags logon_flags,
CMC_session_id FAR *session,
CMC_extension FAR *logon_extensions
);

extern LPFNCMCLOGON lpfnCMCLogon; 其中CMC_return_code、CMC_string 、CMC_enum、CMC_ui_id 、CMC_uint16、CMC_flags、CMC_session_id FAR、
CMC_extension FAR 都是基本的数据结构。我实在是看不懂这样的typedef是什么意思,有什么作用
...全文
140 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
shitalone 2003-02-26
  • 打赏
  • 举报
回复
同意楼上小鸟的观点。
yym314 2003-02-26
  • 打赏
  • 举报
回复
define function pointer!
LPFNCMCLOGON is a pointer, point to
CMC_return_code function(
CMC_string service,
CMC_string user,
CMC_string password,
CMC_enum character_set,
CMC_ui_id ui_id,
CMC_uint16 caller_cmc_version,
CMC_flags logon_flags,
CMC_session_id FAR *session,
CMC_extension FAR *logon_extensions
);
Leoparder 2003-02-26
  • 打赏
  • 举报
回复
typedef type-declaration synonym;

The typedef keyword defines a synonym for the specified type-declaration. The identifier in the type-declaration becomes another name for the type, instead of naming an instance of the type. You cannot use the typedef specifier inside a function definition.

A typedef declaration introduces a name that, within its scope, becomes a synonym for the type given by the decl-specifiers portion of the declaration. In contrast to the class, struct, union, and enum declarations, typedef declarations do not introduce new types — they introduce new names for existing types.

Example

// Example of the typedef keyword
typedef unsigned long ulong;

ulong ul; // Equivalent to "unsigned long ul;"

typedef struct mystructtag
{
int i;
float f;
char c;
} mystruct;

mystruct ms; // Equivalent to "struct mystructtag ms;"

typedef int (*funcptr)(); // funcptr is synonym for "pointer
// to function returning int"

funcptr table[10]; // Equivalent to "int (*table[10])();"
yinx 2003-02-26
  • 打赏
  • 举报
回复
指向函数的指针嘛
参数类型是括号里的东西
也就是说:
CMC_return_code myCode;

和 FAR PASCAL *LPFNCMCLOGON)(
CMC_string service,
CMC_string user,
CMC_string password,
CMC_enum character_set,
CMC_ui_id ui_id,
CMC_uint16 caller_cmc_version,
CMC_flags logon_flags,
CMC_session_id FAR *session,
CMC_extension FAR *logon_extensions
) myCode;


作用一样



qrlvls 2003-02-26
  • 打赏
  • 举报
回复
定义函数指针类型
dozoo 2003-02-26
  • 打赏
  • 举报
回复
学习
cnwolf 2003-02-26
  • 打赏
  • 举报
回复
typedef 的作用是重新定义类型

typedef int aaa;

定义了一个类型aaa,他和int相同

int a;
aaa a;
就会产生同样的作用

你的例子是定义了一个函数指针类型LPFNCMCLOGON
XiangDong 2003-02-26
  • 打赏
  • 举报
回复
这是指针没有函数实体的
用于将来指向该种类型的函数
dizzo 2003-02-26
  • 打赏
  • 举报
回复
FAR PASCAL
是函数调用方法,也就是__stdcall,参数从右向左传,多用于系统调用的API

函数实现在别的地方,这样只是定义了一个指向具有这种参数和返回值的函数的指针而已。

使用时这样使用:

LPFNCMCLOGON pfnFunction;
pfnFunction = FunctionName; //这个就是具体的实现函数的名字,函数名字也就是函数地址。

pfnFunction(...); //这个和调用FunctionName(...);相同




hp_oracle 2003-02-26
  • 打赏
  • 举报
回复
我已经找到了pascal far的解释
hp_oracle 2003-02-26
  • 打赏
  • 举报
回复
那么他就应该有函数实现的,为什么我看不到呢?
还有,那个pascal是干什么用的呢,far又有什么作用呢?
fireseed 2003-02-26
  • 打赏
  • 举报
回复
这样的typedef是定义了一个函数指针,
CMC_string service,
CMC_string user,
CMC_string password,
CMC_enum character_set,
CMC_ui_id ui_id,
CMC_uint16 caller_cmc_version,
CMC_flags logon_flags,
CMC_session_id FAR *session,
CMC_extension FAR *logon_extensions
这些是参数

FAR PASCAL
是函数调用方法,也就是__stdcall,参数从右向左传,多用于系统调用的API
hp_oracle 2003-02-26
  • 打赏
  • 举报
回复
能有中文的解释的吗?

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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