Posts

Showing posts with the label Filenames

.c Vs .cc Vs. .cpp Vs .hpp Vs .h Vs .cxx

Answer : 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, 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. 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 ...

C++ Code File Extension? .cc Vs .cpp

Answer : At the end of the day it doesn't matter because C++ compilers can deal with the files in either format. If it's a real issue within your team, flip a coin and move on to the actual work. GNU GCC recognises all of the following as C++ files, and will use C++ compilation regardless of whether you invoke it through gcc or g++: .C , .cc , .cpp , .CPP , .c++ , .cp , or .cxx . Note the .C - case matters in GCC, .c is a C file whereas .C is a C++ file (if you let the compiler decide what it is compiling that is). GCC also supports other suffixes to indicate special handling, for example a .ii file will be compiled as C++, but not pre-processed (intended for separately pre-processed code). All the recognised suffixes are detailed at gcc.gnu.org Great advice on which to use for the makefile and other tools, considering non-compiler tools while deciding on which extension to use is a great approach to help find an answer that works for you. I just wanted to add ...