.cc和.cpp文件后缀有什么区别? [英] What is the difference between .cc and .cpp file suffix?
问题描述
.cc
和 .cpp
文件扩展名有什么区别?
What is the difference between .cc
and .cpp
file extensions?
我从Google得知它们都是C ++语言,但是我不确定它们之间的区别.
From Google, I learned that they are both from the C++ language, but I am unsure of differences between them.
推荐答案
公约.
从历史上看,C ++源文件的后缀是 .C
.第一次移植C ++时,这引起了一些问题到文件名中大小写无关紧要的系统.
Historically, the suffix for a C++ source file was .C
.
This caused a few problems the first time C++ was ported
to a system where case wasn't significant in the filename.
不同的用户采用了不同的解决方案: .cc
, .cpp
, .cxx
以及其他.今天,在Unix之外世界上主要是 .cpp
.Unix似乎更经常使用 .cc
.
Different users adopted different solutions: .cc
,
.cpp
, .cxx
and possibly others. Today, outside of the Unix
world, it's mostly .cpp
. Unix seems to use .cc
more often.
对于标头,情况更加令人困惑:无论是什么原因,最早的C ++作者决定不区分在C和C ++的标头之间,并使用 .h
.
For headers, the situation is even more confusing: for whatever
reasons, the earliest C++ authors decided not to distinguish
between headers for C and for C++, and used .h
.
如果项目中没有C,这不会引起任何问题,但是当您开始必须同时处理这两个问题,通常这是一个好主意区分可以在C( .h
)中使用的标头以及那些不能( .hh
或 .hpp
)的文件.
This doesn't cause any problems if there is no C in the project, but when you
start having to deal with both, it's usually a good idea to
distinguish between the headers which can be used in C (.h
)
and those which cannot (.hh
or .hpp
).
此外,在C ++中,许多用户(包括我自己)都喜欢保留模板源代码和内联函数在单独的文件中.哪一个,虽然严格来说是头文件,但往往会得到另一个一组约定( .inl
, .tcc
,可能还有很多其他).
In addition, in C++, a lot of users (including myself) prefer keeping the template
sources and the inline functions in a separate file. Which,
while strictly speaking a header file, tends to get yet another
set of conventions (.inl
, .tcc
and probably a lot of
others).
对于标头,它对编译器绝对没有影响.
In the case of headers it makes absolutely no difference to the compiler.
对于源文件,不同的结尾将导致编译器采用不同的名称语.但这通常可以被覆盖,我使用了 .cc
早在VC ++将其识别为C ++之前就已经使用VC ++.
In the case of source files different endings will cause the compiler to assume a different
language. But this can normally be overridden, and I used .cc
with VC++ long before VC++ recognized it as C++.
这篇关于.cc和.cpp文件后缀有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!