0

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!

  • Wow! In this day and age, they have this K&R style function! That is ummm...antique by today's standards, ANSI/ISO C became de-facto in 1989 which specified that function declarations include the parameter and its data type at the same time, i.e. int itsfoubare(char *fname) which is what most C compilers use. I am amazed at this, plus the french spelling for foobar or fubar which is the more accurate spelling! I like this question as it is unusual to see old K&R code lying around. – t0mm13b Nov 27 '09 at 12:42

4 Answers4

1

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.

Community
  • 1
  • 1
int3
  • 12,861
  • 8
  • 51
  • 80
  • Yep thats the answer the linked post explains it very good, thank you! –  Nov 27 '09 at 12:24
0

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

Sylvestre
  • 352
  • 1
  • 7
0

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

Carl Smotricz
  • 66,391
  • 18
  • 125
  • 167
0

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)
}
pmg
  • 106,608
  • 13
  • 126
  • 198