gcc编译以“.C”结尾的c文件(Capital C)

时间:2013-03-19 22:27:11

标签: c gcc

我shell时的奇怪行为:

bush@ubuntu:~/CPPWorkspace/Ex12$ gcc users/dubi/justPrnit.C

返回错误:

gcc: error trying to exec 'cc1plus': execvp: No such file or directory

但是当我将justPrnit.C更改为justPrnit.c(带有小'c')时,它已成功编译。

那是什么?

2 个答案:

答案 0 :(得分:8)

  

错误尝试执行'cc1plus'

因为假设.C是C ++源文件(cc1plus是GCC的C ++解析器后端 - 顺便说一句,看来你的本地GCC安装缺少g++ - 你使用默认的[不完整]设置吗?)。

要解决此问题,请使用-x开关强制语言:

gcc -x c users/dubi/justPrnit.C

答案 1 :(得分:2)

GCC将.C识别为C ++,而不是C