Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What weird C syntax is this? [duplicate]

Tags:

c

syntax

Possible Duplicates:
C variable declarations after function heading in definition
What is useful about this C syntax?

I trying to understand some C code and came across this where variables are declared between the head of the function and the first brace.

Any Idea what these variables are?
Are they local or global?

What does the author intend to do here?

void someFunction (m_ptr, n_ptr, params, err)
            integer  *m_ptr;        /* pointer to number of points to fit */
            integer  *n_ptr;        /* pointer to number of parameters */
            doublereal *params;     /* vector of parameters */
            doublereal *err;        /* vector of error from data */
        {
            //some variables declared here
            int       i;
            ...
            ...

            //body of the function here

        }
like image 224
Kevin Boyd Avatar asked Dec 07 '10 19:12

Kevin Boyd


2 Answers

They are function arguments. This is an alternative way to declare them. They work the same way as normal arguments.

For a rather long but very informative explanation see Alternative (K&R) C syntax for function declaration versus prototypes

like image 175
terminus Avatar answered Sep 28 '22 06:09

terminus


Those variables are a declaration of the arguments. Not sure why anyone use that style any more. Those types must be typedef's though.

If this is old legacy code, did void really exist as a keyword back then?

like image 37
onemasse Avatar answered Sep 28 '22 06:09

onemasse