В C ++ я склонен в некоторых случаях опускать имя параметра. Но в C я получал ошибку, когда не указывал имя параметра.
Вот код:
void foo(int); //forward-decl, it's OK to omit the parameter's name, in both C++ and C
int main()
{
foo(0);
return 0;
}
void foo(int) //definition in C, it cannot compile with gcc
{
printf("in foo\n");
}
void foo(int) //definition in C++, it can compile with g++
{
cout << "in foo" << endl;
}
Почему? Могу ли я опустить имя параметра в определении функции C?