Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does this declaration come from: main _2a((argc,argv), int argc, char * argv[])

Tags:

c

oracle-pro-c

I am migrating lots of Oracle Pro*C Code under HP-Unix to a Linux Environment.

In a program there is only such a main method defined:

main _2a((argc,argv), int argc, char * argv[])
{
...
}

I have never seen such a decalaration before - and haven't found anything with google. Anyhow, it works and from what I see is used as a main function.

Can anybody tell something about this?

Edit: Good hint - there is a macro definition:

 # define _2a(list,a1,a2)                 list a1;a2;

Still makes no clear view (for me..)

like image 865
Stefan Avatar asked Nov 18 '14 15:11

Stefan


1 Answers

This macro is used to make K&R C-style function definition look more like "modern" C89 definitions.

Expanded the code reads:

main (argc,argv) int argc;char * argv[];
{
...
}

Or with a better indentation:

main(argc, argv)
    int argc;
    char *argv[];
{
    ...
}

Which is an ancient way to write:

int main(int argc, char *argv[])
{
    ...
}
like image 108
kay Avatar answered Oct 24 '22 13:10

kay