22

What is "XX" in CXX in a cmake CMakeLists.txt file.
What is its significance.

Why is it "XX" not PP against a CPP file ?

Aykhan Hagverdili
  • 28,141
  • 6
  • 41
  • 93
user2618142
  • 1,035
  • 2
  • 18
  • 35

2 Answers2

43

XX stands for "++" (each X is like a "plus" rotated by 45°), CXX stands for "C++".

Why "CXX"?

  • "C++" is not possible because of macro identifiers limitations (they can't contain a +);
  • "CPP" (for "C Plus Plus") is usually already used to stand for "C PreProcessor".

For example in a GNU Makefile you can define the following "variables":

  • CPPFLAGS : extra flags for the C preprocessor (also used in C++).
  • CFLAGS   : extra flags for the C compiler.
  • CXXFLAGS : extra flags for the C++ compiler.

(Usually you will use CPPFLAGS and CFLAGS for a C project, and CPPFLAGS and CXXFLAGS for a C++ project.)


See also Difference between CPPFLAGS and CXXFLAGS in GNU Make and CFLAGS vs CPPFLAGS.

Also related: Correct C++ file extension (and duplicate links).

Community
  • 1
  • 1
gx_
  • 4,690
  • 24
  • 31
6

Many filesystems do not allow + in filenames, which is why a number of naming conventions emerged for C++ source files over the years, inlcuding .cpp, .cc and .cxx.

CMake has a similar problem as its macro language is built around strings that are not allowed to hold special characters like +. This is simply a limitation to keep CMake's parser from becoming too complicated. So whenever they write CXX, what they really mean is just C++.

ComicSansMS
  • 51,484
  • 14
  • 155
  • 166