.C VS .CC主场迎战的.cpp VS .HPP VS .H VS .CXX [英] .c vs .cc vs. .cpp vs .hpp vs .h vs .cxx
问题描述
可能显示的文件:结果
的* .h或* .HPP为您的类定义结果
正确的C ++ code文件扩展名?名为.cc VS的.cpp
我曾经认为它曾经是:
-
.H
文件头C和C ++的文件,通常只包含声明。 -
.C
文件是C源程序code。 -
的.cpp
文件是C ++源$ C $ C(也可以是C源$ C $ C)。
.h
files are header files for C and C++, and usually only contain declarations..c
files are C source code..cpp
files are C++ source code (which can also be C source code).
然后文件,如 .HPP
, .CC
和 .CXX
走来了,我完全糊涂了......什么是那些之间的差值(S)?当你用新的?
then files like .hpp
, .cc
, and .cxx
came along, and I got totally confused... what's the difference(s) between those? When do you use the "new" ones?
推荐答案
从历史上看,用于C ++是第一个扩展 .C
和 .H
,酷似为C.这导致了实际问题,特别是 .C
这并没有让构建系统很容易区分C ++和C文件。
Historically, the first extensions used for C++ were .c
and .h
, exactly like for C. This caused practical problems, especially the .c
which didn't allow build systems to easily differentiate C++ and C files.
Unix下,在其C ++已经研制成功,具有区分大小写的文件系统。因此,一些使用 .C
C ++文件。其他使用 .C ++
, .CC
和 .CXX
。 .C
和 .C ++
有问题,他们不提供其他文件系统及其使用快速回落的问题。 DOS和Windows C ++编译器倾向于使用的.cpp
,其中一些作出选择困难,如果不是不可能的,要配置。便携性的考虑做了这个选择中最常见的,甚至外MS-Windows操作系统。
Unix, on which C++ has been developed, has case sensitive file systems. So some used .C
for C++ files. Other used .c++
, .cc
and .cxx
. .C
and .c++
have the problem that they aren't available on other file systems and their use quickly dropped. DOS and Windows C++ compilers tended to use .cpp
, and some of them make the choice difficult, if not impossible, to configure. Portability consideration made that choice the most common, even outside MS-Windows.
头已经使用了相应的 .H
, .H ++
, .hh
, .HXX
和 .HPP
。但不同的是主文件,的.h
仍然是这一天的C ++的流行选择甚至与缺点,即它不允许知道,如果报头可以被包括用C上下文或没有。标准的头现在已经没有扩展名的。
Headers have used the corresponding .H
, .h++
, .hh
, .hxx
and .hpp
. But unlike the main files, .h
remains to this day a popular choice for C++ even with the disadvantage that it doesn't allow to know if the header can be included in C context or not. Standard headers now have no extension at all.
此外,一些正在使用。②
, .ixx
, .ipp
, .INL
页眉提供内嵌的定义和 .txx
,。 TPP
和 .tpl
模板定义。那些要么包括在报头提供的定义,或手工需要它们的上下文
Additionally, some are using .ii
, .ixx
, .ipp
, .inl
for headers providing inline definitions and .txx
, .tpp
and .tpl
for template definitions. Those are either included in the headers providing the definition, or manually in the contexts where they are needed.
编译器和工具通常不关心扩展使用什么,但使用它们关联用C ++ $ P $扩展pvents需要跟踪如何配置他们,使他们正确识别所使用的语言。
Compilers and tools usually don't care about what extensions are used, but using an extension that they associate with C++ prevents the need to track out how to configure them so they correctly recognise the language used.
这篇关于.C VS .CC主场迎战的.cpp VS .HPP VS .H VS .CXX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!