# GCC Compatibility and Interoperability

## GCC Compatibility

The Intel® C++ Compiler Classic is compatible with most versions of the GNU Compiler Collection (GCC). The release notes contains a list of compatible versions.

C language object files created with the compiler are binary compatible with the GCC and C/C++ language library. You can use the Intel® C++ Compiler Classic or the GCC compiler to pass object files to the linker.To pass IPO mock object files or libraries of IPO mock object files produced by theIntel® C++ Compiler Classic to the linker, use the linking tools provided with the compiler. Specifically:

Use icc, icpc, xild, and xiar.

### Note

When using an Intel software development product that includes a compiler with a Clang front-end, you can also use icl.

Link-time optimization using the -ffat-lto-objects compiler option is provided for GCC compatibility. This implies that ld and ar can be used to link and archive object files, but by doing so you will lose cross-file optimizations. You can use the -fno-fat-lto-objects compiler option when linking using IPO mock object files, provided that you link the IPO mock object files with xild and archive them with xiar.

The Intel® C++ Compiler Classic supports many of the language extensions provided by the GNU compilers.

Statement expressions are supported, except that the following are prohibited inside them:

- Dynamically-initialized local static variables

- Local non-POD class definitions

- Try/catch

- Variable length arrays

Branching out of a statement expression and statement expressions in constructor initializers are not allowed. Variable-length arrays are no longer allowed in statement expressions.

The Intel® C++ Compiler Classic supports GCC-style inline ASM if the assembler code uses AT&T* System V/386 syntax.

## GCC Interoperability

C++ compilers are interoperable if they can link object files and libraries generated by one compiler with object files and libraries generated by the second compiler, and the resulting executable runs successfully. The Intel® C++ Compiler Classic is highly compatible with the GNU compilers.

The Intel® C++ Compiler Classic and GCC support the following predefined macros:

- `__GNUC__`
- `__GNUG__`
- `__GNUC_MINOR__`
- `__GNUC_PATCHLEVEL__`

### CAUTION

Not defining these macros results in different paths through system header files. These alternate paths may be poorly tested or otherwise incompatible.

## How the Compiler Uses GCC

The Intel® C++ Compiler Classic uses the GNU tools on the system, such as the GNU header files, including stdio.h, and the GNU linker and libraries. So the compiler has to be compatible with the version of GCC or G++* you have on your system. For example, if you have GCC version 4.6 on your system, `icc` behaves like GCC 4.6, with the compatible features and behaviors.

By default, the compiler determines which version of GCC or G++ you have installed from the `PATH` environment variable.

If you want use a version of GCC or G++ other than the default version on your system, you need to use the `--gcc-toolchain` compiler option to specify the location of the base toolchain. For example:

- You want to build something that cannot be compiled by the default version of the system compiler, so you need to use a legacy version for compatibility, such as if you want to use third party libraries that are not compatible with the default version of the system compiler.

- You want to use a later version of GCC or G++ than the default system compiler.

The Intel® C++ Compiler Classic driver uses the default version of GCC/G++, or the version you specify, to extract the location of the headers and libraries.

## Compatibility with Open Source Tools

The Intel® C++ Compiler Classic includes improved support for the following open source tools:

- GNU Libtool: A script that allows package developers to provide generic shared library support.

- Valgrind: A flexible system for debugging and profiling executables running on x86 processors.

- GNU Automake: A tool for automatically generating Makefile.ins from files called Makefile.am.

Parent topic: Compatibility and Portability

## See Also

ffat-lto-objects