What is the difference between g++ and gcc?

后端 未结 10 2155
无人共我
无人共我 2020-11-22 00:34

What is the difference between g++ and gcc? Which one of them should be used for general c++ development?

10条回答
  •  迷失自我
    2020-11-22 00:47

    I was testing gcc and g++ in a linux system. By using MAKEFILE, I can define the compliler used by "GNU make". I tested with the so called "dynamic memory" locating feature of "C plus plus" by :

    int main(){
    
    int * myptr = new int;
    * myptr = 1;
    printf("myptr[0] is %i\n",*myptr);
    return 0;
    }
    

    Only g++ can successfully compile on my computer while gcc will report error

    undefined reference to `operator new(unsigned long)'
    

    So my own conclusion is gcc does not fully support "C plus plus". It seems that choosing g++ for C++ source files is a better option.

提交回复
热议问题