On Jun 4, 6:21*am, Steven Woody <narkewo...@gmail.comwrote:
Hi,
I usually write c code in .c files and use c compiler to compile
them. *In this new project, my team member prefer to write c code
in .cpp and use c++ compiler *to make them. *Which method is better?
In particularly, the compiler is gnu gcc and g++, our OS is linux.
Call your C files ".c" and your C++ files ".cpp". Your IDE "Integrated
Development Environment" should use the appropriate compiler for each.
You should _not_ use a C++ compiler to compile C code, mostly because
there's plenty of legal C code that won't compile with a C++ compiler.
Consider the following:
void Func(const i) /* Error implicit int */
{
int *parr[10];
int try; /* Error keyword used as variable name */
for (try = 0; try != 10; ++try)
{
parr[try] = malloc(sizeof(int));
if (parr[try]) *(parr[try]) = val;
/* Error implicit conv from void* to int* */
}
}
You should REALLY dissuade your collegue from compiling C code as C++.