在 Shell 中使用别名 CC 来引用 Clang?
在我的默认 shell - zsh 中使用别名 cc 来引用 Clang (大概是通过编辑我的 .zshrc 文件),同时在另一个 shell (bash) 中将 cc 别名为 gcc 时,有任何警告或陷阱吗?
我发现 Clang 更容易使用,主要是因为它的警告和错误消息比 gcc 更容易阅读和理解。下学期我将参加 Unix 编程课程(纯 C 语言),并预计在提交作业之前清除所有 gcc -Wall
警告。
我想做的是在我的默认 shell (zsh) 中使用 Clang 进行大部分开发,使用 makefile 将编译器引用为 cc。一旦满意,我将在提交之前通过 bash (调用 gcc 作为编译器)运行一次,作为测试。提交的 makefile 以 cc 作为编译器,然后将为讲师调用 gcc,使其对他们透明。我应该在每次作业中提交 makefile。
我知道这看起来像是懒惰,因为我每次都可以重新编辑 makefile,但我试图减少出错的空间。
Any caveats or gotchas to aliasing cc to refer to Clang within my default shell - zsh (presumably by editing my .zshrc file) while leaving cc aliased to gcc in another shell (bash)?
I find Clang much easier to use mainly because it's warnings and error messages are much more readable and understandable than those of gcc. I will be enrolled in a Unix programming course next semester (purely in C) and am expected to have cleared any gcc -Wall
warnings before submission of an assignment.
What I am trying to do is do most of my developing using Clang within my default shell (zsh) using a makefile that refers to the compiler as just cc. Once satisfied I would run it once, as a test, via bash (invoking gcc as the compiler) before submitting. The submitted makefile with cc as the compiler would then invoke gcc for the instructor, making it transparent to them. I am supposed to submit makefiles with each assignment.
I know this just seems like lazyness since I can re-edit the makefile each time, but I am trying to leave less room for error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需运行
or
or Maybe
(提醒:
-flto
应在编译时和链接时传递)。Just run
or
or perhaps
(reminder:
-flto
should be passed at compile and at link time).我不会评论这是否好,但有一个更简单的方法。只需在 Makefile 中使用一个变量即可达到您想要的默认值:
然后您可以在调用 make 时覆盖它:
I won't comment on whether this is fine or not, but there is an easier way. Just use a variable in your Makefile to whatever you want the default to be:
Then you can override this when you invoke make: