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!
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.
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)
.
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)
}
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