遇到不常见的C函数定义,真是少见,Sybase的官方代码

52cpp 2014-08-25 07:50:54
/*
** Client-Library error handler. This function will be invoked
** when a Client-Library has detected an error. Before Client-
** Library routines return CS_FAIL, this handler will be called
** with additional error information.
*/
CS_RETCODE CS_PUBLIC
clientmsg_callback(context, conn, emsgp)
CS_CONTEXT *context;
CS_CONNECTION *conn;
CS_CLIENTMSG *emsgp;

{

/*
** Error number: Print the error's severity, number, origin, and
** layer. These four numbers uniquely identify the error.
*/
fprintf(ERR_CH,
"Client Library error:\n\t");
fprintf(ERR_CH,
"severity(%ld) number(%ld) origin(%ld) layer(%ld)\n",
(long)CS_SEVERITY(emsgp->severity),
(long)CS_NUMBER(emsgp->msgnumber),
(long)CS_ORIGIN(emsgp->msgnumber),
(long)CS_LAYER(emsgp->msgnumber));

/*
** Error text: Print the error text.
*/
fprintf(ERR_CH, "\t%s\n", emsgp->msgstring);

/*
** Operating system error information: Some errors, such as
** network errors, may have an operating system error associated
** with them. If there was an operating system error, this code
** prints the error message text.
*/
if (emsgp->osstringlen > 0)
{
fprintf(ERR_CH,
"Operating system error number(%ld):\n",
(long)emsgp->osnumber);
fprintf(ERR_CH, "\t%s\n", emsgp->osstring);
}

/*
** If we return CS_FAIL, Client-Library marks the connection as
** dead. This means that it cannot be used anymore. If we return
** CS_SUCCEED, the connection remains alive if it was not already
** dead.
*/
return (CS_SUCCEED);
}


大神们,红色部分是什么格式的函数定义?怎么才能编译通过?
...全文
132 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2014-08-25
  • 打赏
  • 举报
回复
C Function Definitions A function definition specifies the name of the function, the types and number of parameters it expects to receive, and its return type. A function definition also includes a function body with the declarations of its local variables, and the statements that determine what the function does. Syntax translation-unit : external-declaration translation-unit external-declaration external-declaration : /* Allowed only at external (file) scope */ function-definition declaration function-definition : /* Declarator here is the function declarator */ declaration-specifiersopt attribute-seqopt declarator declaration-listopt compound-statement /* attribute-seq is Microsoft Specific */ Prototype parameters are: declaration-specifiers : storage-class-specifier declaration-specifiers opt type-specifier declaration-specifiers opt type-qualifier declaration-specifiers opt declaration-list : declaration declaration-list declaration declarator : pointeropt direct-declarator direct-declarator : /* A function declarator */ direct-declarator ( parameter-type-list ) /* New-style declarator */ direct-declarator ( identifier-list opt ) /* Obsolete-style declarator */ The parameter list in a definition uses this syntax: parameter-type-list : /* The parameter list */ parameter-list parameter-list , ... parameter-list : parameter-declaration parameter-list , parameter-declaration parameter-declaration : declaration-specifiers declarator declaration-specifiers abstract-declarator opt The parameter list in an old-style function definition uses this syntax: identifier-list : /* Used in obsolete-style function definitions and declarations */ identifier identifier-list , identifier The syntax for the function body is: compound-statement : /* The function body */ { declaration-list opt statement-list opt } The only storage-class specifiers that can modify a function declaration are extern and static. The extern specifier signifies that the function can be referenced from other files; that is, the function name is exported to the linker. The static specifier signifies that the function cannot be referenced from other files; that is, the name is not exported by the linker. If no storage class appears in a function definition, extern is assumed. In any case, the function is always visible from the definition point to the end of the file. The optional declaration-specifiers and mandatory declarator together specify the function’s return type and name. The declarator is a combination of the identifier that names the function and the parentheses following the function name. The optional attribute-seq nonterminal is a Microsoft-specific feature defined in Function Attributes. The direct-declarator (in the declarator syntax) specifies the name of the function being defined and the identifiers of its parameters. If the direct-declarator includes a parameter-type-list, the list specifies the types of all the parameters. Such a declarator also serves as a function prototype for later calls to the function. A declaration in the declaration-list in function definitions cannot contain a storage-class-specifier other than register. The type-specifier in the declaration-specifiers syntax can be omitted only if the register storage class is specified for a value of int type. The compound-statement is the function body containing local variable declarations, references to externally declared items, and statements. The sections Function Attributes, Storage Class, Return Type, Parameters, and Function Body describe the components of the function definition in detail.
勤奋的小游侠 2014-08-25
  • 打赏
  • 举报
回复
老版本的c代码 参考 http://topic.csdn.net/u/20090521/16/7e836924-2321-40c6-89b6-f20630b4415e.html http://topic.csdn.net/u/20080827/18/29608fc0-db9a-4a5d-b8c0-c4118f97b27e.html http://support.microsoft.com/kb/79845/zh-cn 7.0 和更高版本所在的 Microsoft C/C++ 编译器版本不支持 C++ 文件中的旧样式函数声明。 旧样式声明仍然受支持 C 文件中。 有时称为 K&R 的声明的旧样式声明都有中的声明是在括号内列出的任何参数。 例如: void KRfunc();  /* declaration */ void KRfunc(a, b)  /* definition */ int a; char b; { } C++ 需要 ANSI 样式函数原型 (或声明),哪个列表每个参数的类型由该函数接受,如下所示:   void ANSIfunc(int a, char b); 需要此类型的声明,,因为在 C++ 中每个函数有一个签名。 签名由该函数和接受该参数的类型的名称组成。 编译器无法构造从 K&R 声明的函数的签名。
52cpp 2014-08-25
  • 打赏
  • 举报
回复
引用 2 楼 mymtom 的回复:
K&R风格的函数定义
怎么才能在VS2010中编译通过呢?
52cpp 2014-08-25
  • 打赏
  • 举报
回复
怎么才能在VS2010中编译通过呢?
mymtom 2014-08-25
  • 打赏
  • 举报
回复
K&R风格的函数定义
52cpp 2014-08-25
  • 打赏
  • 举报
回复
CS_RETCODE CS_PUBLIC clientmsg_callback(context, conn, emsgp) CS_CONTEXT *context; CS_CONNECTION *conn; CS_CLIENTMSG *emsgp;</span> { 。。。 } 我说的是这一段

64,282

社区成员

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

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