What does underscore as an argument in C mean?

All modern compilers (clang 3.6, gcc 4.8) allow you to write functions with _in the argument list. Like this:

int func(_)
{
    return 1;
}

Even mainallows such an argument ( int main(_))

The only warning is

p1_concat.c: 31: 5: warning: type '_ defaults to' int [enabled by default]

What does this underline mean?

+4
source share
2 answers

The underscore _is a valid regular identifier. The definition of such a function:

type function(arg1, arg2, arg3)
{
    ...
}

(i.ee ) - ANSI, K & R. int, , :

type function(arg1, arg2, arg3)
    type arg1;
    type arg2;
    type arg3;
{
    ...
}

type arg1; - . - , . _, int.

+4

int func(_)
{
    return 1;
}

- , _ ().

. C ( 6.9.1)

6 , , , , .

, ,

int func(_)
int _;
{
    return 1;
}

int main(_)
{
   //...
}

, _,

int main(_)
int _;
{
   //...
}

C . , .

0

Source: https://habr.com/ru/post/1629175/


All Articles