Scilab<->C 接口中奇怪的函数定义

发布于 2024-08-12 20:52:24 字数 441 浏览 4 评论 0 原文

我正在谈论 Scilab<->C 包装器的示例: http:// /www.scilab.org/doc/intro/node89.html

奇怪的部分是这个:

int intsfoubare(fname) 
 char *fname;
   {
     ....(some code)
   }

它是某种函数定义,但我真的不明白 char *fname 有什么用处,而且 fname 作为参数对我来说毫无意义。

有人能解释一下吗?

[开始哭泣] 一般来说,Scilabs 文档是一个反面例子,但当涉及到 C 接口时,情况甚至更糟。 [哭完]

谢谢!

I'am talking about this example of a Scilab<->C wrapper: http://www.scilab.org/doc/intro/node89.html.

The strange part is this one:

int intsfoubare(fname) 
 char *fname;
   {
     ....(some code)
   }

It is some kind of function defintion but I really don't understand what the char *fname is good for also just fname as parameter makes no sense to me.

Is someone able to explain this?

[start crying]
Scilabs documentation in general is a negative example but when it comes to the C-interface it's even worse.
[end crying]

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

奈何桥上唱咆哮 2024-08-19 20:52:24

我相信您看到的是 K&R 风格的函数声明。它大约相当于 int intsfoubare(char *fname) { ... },但在调用函数时允许更灵活。有关更多详细信息,请参阅这篇文章

I believe what you're looking at is the K&R style of function declaration. It's approximately equivalent to int intsfoubare(char *fname) { ... }, but allows more somewhat more flexibility in calling the function. See this post for more details.

七禾 2024-08-19 20:52:24

我不懂 Scilab,但我懂法语!

“foubare”听起来像法语“foobar”。这可能是某些开发人员(不小心?)留下的虚拟或测试函数的情况。

fname 听起来像文件名的名称,作为字符指针传入。

也许这会有所帮助。

至于 fname 的使用方式:在较旧的“经典”C 语言定义中,仅将传递参数的名称放在括号中是(事实上仍然是)合法的,并且稍后声明其类型。你不会再看到太多这样的情况了,但这也不是完全错误的。假装括号里写着 (char *fname)

I don't know Scilab, but I know French!

"foubare" sounds like French for "foobar". This could be a case of a dummy or test function some developer (accidentally?) left in place.

fname sounds like the name of a file name, passed in as a character pointer.

Maybe this will help a bit.

As for the way that fname is used: In the older, "classic" C language definition, it was (in fact still is) legal to put just the name of a passed parameter in the parentheses, and declare its type later. You don't see much of that any more, but it's not totally wrong either. Just pretend the parentheses say (char *fname) .

送君千里 2024-08-19 20:52:24

这是旧式(1989 年 ANSI/ISO 标准化 C 之前)函数的定义。
如今,有了原型,它就被写成(尽管旧的风格仍然被接受):

int intsfoubare(char *fname)
{
    ....(some code)
}

That's the old style (before ANSI/ISO standardized C in 1989) definition of functions.
Nowadays with prototypes it is written (though the old style is still accepted) as

int intsfoubare(char *fname)
{
    ....(some code)
}
没企图 2024-08-19 20:52:24

根据记录,有关此主题的 Scilab 文档现在好多了!

请参阅:http://help.scilab.org/docs/current/en_US/api_scilab .html

For the record, the Scilab documentation on this subject is now way better!

See: http://help.scilab.org/docs/current/en_US/api_scilab.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文