gcc решает какой компилятор использовать в зависимости от разширения исходника
man 1 gcc
---[cut]---
For any given input file, the file name suffix determines
what kind of compilation is done:
file.c
C source code which must be preprocessed.
file.i
C source code which should not be preprocessed.
file.ii
C++ source code which should not be preprocessed.
file.m
Objective-C source code. Note that you must link with
the library libobjc.a to make an Objective-C program
work.
file.mi
Objective-C source code which should not be prepro-
cessed.
file.h
C header file (not to be compiled or linked).
file.cc
file.cp
file.cxx
file.cpp
file.c++
file.C
C++ source code which must be preprocessed. Note that
in .cxx, the last two letters must both be literally
x. Likewise, .C refers to a literal capital C.
file.f
file.for
file.FOR
Fortran source code which should not be preprocessed.
file.F
file.fpp
file.FPP
Fortran source code which must be preprocessed (with
the traditional preprocessor).
---[cut]---