Difference Between .cc and .cpp File Extensions in C++

In C++, we use different file extensions to store our code. Two of the most common extensions are .cc and .cpp both store C++ codes. Although they both are used for the same purpose yet there are some differences between them. In this article, we will learn the key differences between the .cc and .cpp file extensions in C++.

.cc File Extension in C++

A file with a .cc extension is a C++ source code file. The .cc file extension is commonly used in Unix-based systems for C++ source files. This extension is shorter and faster to type, which can be a convenience for developers and it is also compatible with  Mac, Linux, and Windows operating systems.

Syntax to Save C++ Code File With .cc

Simply, enter the name of your file followed by the .cc extension.

fileName.cc

.cpp File Extension in C++

A file with a .cpp extension is also a C++ source code file. This file extension is more commonly used outside of Unix based system. It is widely recognized by various C++ compilers and is often the default file extension for C++ source files and it is also compatible with the Windows operating system and Linux/Mac OS(by using some external programs).

Syntax to Save C++ Code File With .cpp

Simply, enter the name of your file followed by the .cpp extension.

fileName.cpp

Difference Between .cc and .cpp File Extensions

The below table illustrates the primary differences between .cc and .cpp file extensions:

Feature

.cc File Extension

.cpp File Extension

Usage

It is generally used in Unix/Linux based system

It is commonly used in windows.

Typing Speed

It is faster to type due to fewer characters.

It takes slightly longer to type.

Compatibility

This file extension is supported by Unix, GNU C++, Clang, Microsoft Visual C++, and Metrowerks CodeWarrior.

This file extension is supported by GNU C++ , Clang, Digital Mars, Borland C++, Watcom, Microsoft Visual C++, and Metrowerks CodeWarrior. 

External Factor

 .cc extension is used by Google.

 LLVM libc++ use the .cpp file extension.

Conclusion

In conclusion, the choice between the .cc and .cpp file extensions in C++ depends largely on the developer’s preference and the conventions of the system they are working on. Both extensions are recognized by C++ compilers and can be used to store C++ code. Understanding the key differences between these two file extensions can help developers make informed decisions about which extension to use in their projects.


Contact Us