views:

265

answers:

1
  1. I could compile the void main() as c++ source file with microsoft c/c++ compiler 14.00 (integrated with visual studio 2005).So does it means that the compiler does not conform to the c++ standard on the main function prototype?

  2. Is the microsoft c/c++ compiler only one compiler,that is,it is only one c++ compiler?Because C source file could be compiled as C++ source file,so its no need to develop the c compiler anymore?

    thanks.

+5  A: 

I could compile the void main()

The valid signatures of main are:

int main(void); // no parameters 
int main(int, char **); // parameterized

Everything else is not standard. The standard does allow an implementation to allow alternate signatures of main().

Is the microsoft c/c++ compiler only one compiler,that is,it is only one c++ compiler?

Yes, it is one executable (cl.exe). However, it can work either as a C compiler or a C++ compiler. The default is C++ compiler mode. You can change this by going into Project Properties > C/C++ > Advanced (/TP or /TC)

dirkgently
It also infers a default from the file extension (.c or .cpp/.cxx)
Alex