[{"data":1,"prerenderedAt":27},["ShallowReactive",2],{"article:cpp-vs-cxx-difference-cpp-file-extensions:en":3},{"articleId":4,"id":5,"title":6,"slug":7,"meta_description":8,"excerpt":9,"languageCode":10,"keywords":11,"seedKeyword":12,"created_at":19,"updated_at":19,"_source":20,"content_html":21,"content_markdown":22,"illustration_url":23,"alternateSlugs":24},32,310002,".cpp vs .cxx: what is the difference between C++ file extensions?","cpp-vs-cxx-difference-cpp-file-extensions","There is no language difference: .cpp, .cxx, .cc and .C are all C++ source files. Learn why several extensions exist, how compilers treat them and which to use.",".cpp, .cxx and .cc all contain C++ source code. The extension is a naming convention, not a different language; here is where the variants come from and what to pick.","en-US",[12,13,14,15,16,17,18],"cpp vs cxx",".cxx file",".cpp file","C++ file extensions",".cc file",".hpp","C++ source file","2026-11-09T12:00:00.000Z","manual","\u003Ch1>.cpp vs .cxx: what is the difference between C++ file extensions?\u003C/h1>\n\u003Cp>You open a project and find \u003Ccode>main.cpp\u003C/code> next to \u003Ccode>util.cxx\u003C/code> and \u003Ccode>helper.cc\u003C/code>. Are they different languages? Do they compile differently? Short answer: no. All three are C++ source files, and the extension is mostly a naming convention.\u003C/p>\n\u003Ch2 id=\"tldr\">TL;DR\u003C/h2>\n\u003Cul>\u003Cli>\u003Ccode>.cpp\u003C/code>, \u003Ccode>.cxx\u003C/code>, \u003Ccode>.cc\u003C/code>, \u003Ccode>.c++\u003C/code> and \u003Ccode>.C\u003C/code> are all C++ source files; the code inside is identical in syntax and meaning.\u003C/li>\u003Cli>Which extension a project uses is historical and a matter of style. \u003Ccode>.cpp\u003C/code> is the most common default.\u003C/li>\u003Cli>Compilers use the extension only to decide that a file is C++ (and not C). GCC, Clang and Microsoft's compiler all recognise \u003Ccode>.cpp\u003C/code> and \u003Ccode>.cxx\u003C/code>.\u003C/li>\u003Cli>You can rename \u003Ccode>.cxx\u003C/code> to \u003Ccode>.cpp\u003C/code> without changing the code, but you must update build files that list the old name.\u003C/li>\u003C/ul>\n\u003Ch2 id=\"why-are-there-several-extensions\">Why are there several extensions?\u003C/h2>\n\u003Cp>When C++ appeared, there was no agreed standard for its file names, and different tools picked different ones:\u003C/p>\n\u003Cul>\u003Cli>\u003Cstrong>\u003Ccode>.C\u003C/code>\u003C/strong> (capital C) was used on Unix, where \u003Ccode>.c\u003C/code> meant C and \u003Ccode>.C\u003C/code> meant C++. On case-insensitive file systems such as Windows and macOS the two names collide, so other suffixes were needed.\u003C/li>\u003Cli>\u003Cstrong>\u003Ccode>.cc\u003C/code>\u003C/strong> is common on Unix and in some large code bases.\u003C/li>\u003Cli>\u003Cstrong>\u003Ccode>.cpp\u003C/code>\u003C/strong> (short for \"C plus plus\") became the default on Windows tools and in many IDEs.\u003C/li>\u003Cli>\u003Cstrong>\u003Ccode>.cxx\u003C/code>\u003C/strong> uses the \"x\" as a rotated plus sign and is used by some projects, for example the Visualization Toolkit (VTK).\u003C/li>\u003C/ul>\n\u003Cp>Header files show the same pattern: \u003Ccode>.h\u003C/code>, \u003Ccode>.hpp\u003C/code>, \u003Ccode>.hxx\u003C/code> and \u003Ccode>.hh\u003C/code> are all used for C++ headers.\u003C/p>\n\u003Ch2 id=\"how-do-compilers-treat-them\">How do compilers treat them?\u003C/h2>\n\u003Cp>The compiler does not care about the spelling beyond recognising the language. The GCC manual lists \u003Ccode>.cc\u003C/code>, \u003Ccode>.cp\u003C/code>, \u003Ccode>.cxx\u003C/code>, \u003Ccode>.cpp\u003C/code>, \u003Ccode>.c++\u003C/code> and \u003Ccode>.C\u003C/code> as C++ source, and notes that in \u003Ccode>.cxx\u003C/code> the last two letters must literally be an \"x\". Clang behaves the same way, and Microsoft's compiler treats \u003Ccode>.cpp\u003C/code>, \u003Ccode>.cxx\u003C/code> and \u003Ccode>.cc\u003C/code> as C++ while compiling \u003Ccode>.c\u003C/code> as C by default.\u003C/p>\n\u003Cp>Build systems such as CMake, Make and Visual Studio projects list the source files explicitly or by pattern, so a \u003Ccode>.cxx\u003C/code> file only needs to be included in that list.\u003C/p>\n\u003Ch2 id=\"which-extension-should-you-use\">Which extension should you use?\u003C/h2>\n\u003Cul>\u003Cli>In an existing project, follow what it already uses. Consistency matters more than the choice.\u003C/li>\u003Cli>In a new project, \u003Ccode>.cpp\u003C/code> is the safest choice: every editor, IDE and tool recognises it.\u003C/li>\u003Cli>Avoid a capital \u003Ccode>.C\u003C/code>, because it clashes with \u003Ccode>.c\u003C/code> on case-insensitive systems.\u003C/li>\u003C/ul>\n\u003Ch2 id=\"how-to-open-and-build-a-cxx-file\">How to open and build a .cxx file\u003C/h2>\n\u003Cp>A \u003Ccode>.cxx\u003C/code> file is plain text. You can read it in any text editor or IDE such as Visual Studio Code, Visual Studio, CLion or Notepad++. To build it with GCC, run \u003Ccode>g++ file.cxx -o program\u003C/code>; the output name is up to you.\u003C/p>\n\u003Cp>If a \u003Ccode>.cxx\u003C/code> file does not open as text, check what it really is with our \u003Ca href=\"https://open-the-file.com/tools/header-analyzer\">file header analyzer\u003C/a>.\u003C/p>\n\u003Ch2 id=\"related-guides-on-open-the-filecom\">Related guides on Open-The-File.com\u003C/h2>\n\u003Cul>\u003Cli>\u003Ca href=\"https://open-the-file.com/file-extension/cxx\">What is a .cxx file?\u003C/a>\u003C/li>\u003Cli>\u003Ca href=\"https://open-the-file.com/file-extension/cpp\">What is a .cpp file?\u003C/a>\u003C/li>\u003Cli>\u003Ca href=\"https://open-the-file.com/file-extension/cc\">What is a .cc file?\u003C/a>\u003C/li>\u003Cli>\u003Ca href=\"https://open-the-file.com/file-extension/hpp\">What is a .hpp file?\u003C/a>\u003C/li>\u003C/ul>\n\u003Ch2 id=\"bottom-line\">Bottom line\u003C/h2>\n\u003Cp>\u003Ccode>.cpp\u003C/code> and \u003Ccode>.cxx\u003C/code> are two spellings for the same thing. Pick one per project, stay consistent, and do not worry that either is \"more correct\" for the compiler.\u003C/p>","# .cpp vs .cxx: what is the difference between C++ file extensions?\n\nYou open a project and find `main.cpp` next to `util.cxx` and `helper.cc`. Are they different languages? Do they compile differently? Short answer: no. All three are C++ source files, and the extension is mostly a naming convention.\n\n## TL;DR\n\n- `.cpp`, `.cxx`, `.cc`, `.c++` and `.C` are all C++ source files; the code inside is identical in syntax and meaning.\n- Which extension a project uses is historical and a matter of style. `.cpp` is the most common default.\n- Compilers use the extension only to decide that a file is C++ (and not C). GCC, Clang and Microsoft's compiler all recognise `.cpp` and `.cxx`.\n- You can rename `.cxx` to `.cpp` without changing the code, but you must update build files that list the old name.\n\n## Why are there several extensions?\n\nWhen C++ appeared, there was no agreed standard for its file names, and different tools picked different ones:\n\n- **`.C`** (capital C) was used on Unix, where `.c` meant C and `.C` meant C++. On case-insensitive file systems such as Windows and macOS the two names collide, so other suffixes were needed.\n- **`.cc`** is common on Unix and in some large code bases.\n- **`.cpp`** (short for \"C plus plus\") became the default on Windows tools and in many IDEs.\n- **`.cxx`** uses the \"x\" as a rotated plus sign and is used by some projects, for example the Visualization Toolkit (VTK).\n\nHeader files show the same pattern: `.h`, `.hpp`, `.hxx` and `.hh` are all used for C++ headers.\n\n## How do compilers treat them?\n\nThe compiler does not care about the spelling beyond recognising the language. The GCC manual lists `.cc`, `.cp`, `.cxx`, `.cpp`, `.c++` and `.C` as C++ source, and notes that in `.cxx` the last two letters must literally be an \"x\". Clang behaves the same way, and Microsoft's compiler treats `.cpp`, `.cxx` and `.cc` as C++ while compiling `.c` as C by default.\n\nBuild systems such as CMake, Make and Visual Studio projects list the source files explicitly or by pattern, so a `.cxx` file only needs to be included in that list.\n\n## Which extension should you use?\n\n- In an existing project, follow what it already uses. Consistency matters more than the choice.\n- In a new project, `.cpp` is the safest choice: every editor, IDE and tool recognises it.\n- Avoid a capital `.C`, because it clashes with `.c` on case-insensitive systems.\n\n## How to open and build a .cxx file\n\nA `.cxx` file is plain text. You can read it in any text editor or IDE such as Visual Studio Code, Visual Studio, CLion or Notepad++. To build it with GCC, run `g++ file.cxx -o program`; the output name is up to you.\n\nIf a `.cxx` file does not open as text, check what it really is with our [file header analyzer](https://open-the-file.com/tools/header-analyzer).\n\n## Related guides on Open-The-File.com\n\n- [What is a .cxx file?](https://open-the-file.com/file-extension/cxx)\n- [What is a .cpp file?](https://open-the-file.com/file-extension/cpp)\n- [What is a .cc file?](https://open-the-file.com/file-extension/cc)\n- [What is a .hpp file?](https://open-the-file.com/file-extension/hpp)\n\n## Bottom line\n\n`.cpp` and `.cxx` are two spellings for the same thing. Pick one per project, stay consistent, and do not worry that either is \"more correct\" for the compiler.","/images/articles/hero/cpp-vs-cxx-difference-cpp-file-extensions.webp",{"en":7,"de":25,"it":26},"cpp-vs-cxx-unterschied-c-plus-plus-dateiendungen","cpp-vs-cxx-differenza-estensioni-file-cpp",1794323964650]