When compiling a c file that uses old style function definition like
int foo(a)
int a;
{
...
}
g++ will give and error: ‘a’ was not declared in this scope.
gcc can parse this.
Is there a way to let g++ recognize this?
This comes up as an issue to me because I’m compiling a mix of c and c++ files.
A related question is what’s the standard practice
of building this type of mixed source? Running g++ on all files or only the cc files? The former is convenient but keeps getting me some trouble because of the inconsistencies between c and c++ specification(for example, char[4]=”four”;)
This syntax is not supported in C++.
See e.g. Compiling C++ programs from the GCC docs:
So two possibilities:
gccon C files, andg++on C++ files.gccon all files.In both cases you will need to link with
g++(orgcc -lstdc++).