gcc
- GCC
- nuwen.net/mingw.html
- ftp.equation.com/gcc/gcc-9-20190203-64.exe (using FTP)
- ftp.equation.com/gcc/gcc-9-20190203-32.exe (using FTP)
- examples for filenames: gcc-5.3.0-32.exe, gcc-5.3.0-32.iso, gcc-5.3.0-64.exe, gcc-5.3.0-64.iso, gcc-5.3.0.tar.bz2, gcc-6.3.0-32.exe, gcc-6.3.0-32.iso, gcc-6.3.0-64.exe, gcc-6.3.0-64.iso, gcc-6.3.0.tar.bz2, gcc-7.4.0-32.exe, gcc-7.4.0-32.iso, gcc-7.4.0-64.exe, gcc-7.4.0-64.iso, gcc-7.4.0.tar.xz, gcc-8.2.0-32.exe, gcc-8.2.0-32.iso, gcc-8.2.0-64.exe, gcc-8.2.0-64.iso, gcc-8.2.0.tar.xz, gcc-9-20190127-32.exe, gcc-9-20190127-32.iso, gcc-9-20190127-64.exe, gcc-9-20190127-64.iso, gcc-9-20190127.tar.xz, gcc-9-20190203-32.exe, gcc-9-20190203-32.iso, gcc-9-20190203-64.exe, gcc-9-20190203-64.iso, gcc-9-20190203.tar.xz
Aufrufe von gcc
Allgemeine Warnung Wenn eine Datei erzeugt wird, dann wird eine schon unter dem Namen dieser Datei vorhandene Datei oft ohne Nachfrage ersetzt, also gelöscht. Damit enthalten viele Kommandos ein verstecktes Löschkommando. Deswegen muß man nicht nur vorsichtig sein, wenn man »rm« direkt aufruft.
- Übersetzen und Binden einer Quelldatei (nach »a.out«)
gcc example.c
- Übersetzen ohne Binden (erzeugt die Objektdatei »example.o«)
gcc -c example.c
- Binden der Objektdatei (erzeugt die ausführbare Datei »a.out«)
gcc example.o
- Ausgabe in die Datei »example« statt »a.out«
gcc -o example example.c
gcc -o example example.o
- Binden mehrerer Dateien, gegebenenfalls mit vorherigem Übersetzen
gcc example.c example1.c example2.o example3.o
Einige Optionen
-c
Nur in Objektdatei übersetzen (nicht binden)
-I path
Angabe eines Include -Pfads (vor »-l«)
-L path
Angabe eines Bibliothekspfads (vor »-l«)
-lm
Mathematik-Bibliothek dazubinden (z. B. »-l ws2_32« für »libws2.32.a«, muß hinter »main.c« stehen!)
-x c
Angabe der Programmiersprache C (Alternativen sind unter anderem »-x c«, »-x c-header«, »-x c++«)
-std=c99
Aktuelle C Version (Eine Alternative ist unter anderem »-std=c89« für eine ältere Version)
-pedantic
Genauere Prüfungen der Einhaltung der Sprachspezifikation
-Wall
Mehr Prüfungen für Warnungsmeldungen durchführen
-Wextra
Zusätzliche weitere Prüfungen für Warnungsmeldungen durchführen
-Wa,-adhlns=$(<:.c=.lst) Assembler Ausgabe
-ftrapv -ftrapv This option generates traps for signed overflow on addition, subtraction, multiplication operations. , schaltet entsprechend einige UB-Optimierungen trotz O3 ab
- Option Index
- Beschreibung weiterer Kommandozeilenoptionen
- http://gcc.gnu.org/onlinedocs/gcc/Option-Index.html
C-Konfiguration 1 (FUB 2005)
/usr/bin/gcc \
test.c \
-x c \
-std=c99 \
-pedantic \
-pedantic-errors \
-W \
-Wall \
-Wextra \
-Wmissing-prototypes \
-Wsequence-point \
-Wconversion \
-Wformat-nonliteral \
-Wcast-align \
-Wpointer-arith \
-Wbad-function-cast \
-Wmissing-prototypes \
-Wstrict-prototypes \
-Wmissing-declarations \
-Winline \
-Wundef \
-Wnested-externs \
-Wcast-qual \
-Wshadow \
-Wconversion \
-Wwrite-strings \
-Wno-parentheses \
-Wno-missing-prototypes \
-Wno-missing-declarations \
-Wno-unused-parameter \
-Wno-unused-but-set-variable \
-lm
C++-Konfiguration 1
-D_GLIBCXX_DEBUG
/usr/bin/gcc
main.c
-std=c99
-std=c++11
-std=c++1y
-Weffc++
-O3
-fwhole-program -
g++ test.cpp
-std=c++98
Assemblerausgabe nach stdout
-S -o-
GCC-Erweiterungen
static void escape( volatile void * p )
{ asm volatile( "" : : "g"(p) : "memory" ); }
_int __builtin_constant_p(exp)
__PRETTY_FUNCTION__
__builtin_expect((condition)!=0, 1)
#define X(condition) __builtin_expect((condition)!=0, 0)
#define E(condition) __builtin_expect((condition)!=0, 1)
#define U(condition) __builtin_unpredictable((condition)!=0) /* clang only? */
#define ifx( expr ) if( X( expr ))
#define whilee( expr ) while( E( expr ))
__attribute__((noinline,cold))
static void f()
...
__attribute__((pure))
__COUNTER__
/* for GCC C++ */
#include <cxxabi.h>
#include <iostream>
#include <ostream>
#include <typeinfo>
#include <string>
using namespace ::std::literals;
struct entity { double entity{ 25 }; };
const char* decode( const char * const typnam )
{ static char buf[ 999 ]; size_t size = sizeof( buf ); int st;
char const * const result = ::abi::__cxa_demangle( typnam, buf, &size, &st );
buf[ size - 1 ]= 0; return result; }
int main()
{ auto ff = []{};
::std::cout << decode( typeid( []{} ).name() )<< '\n';
::std::cout << decode( typeid( ff ).name() )<< '\n';
::std::cout << decode( typeid( (+ff) ).name() )<< '\n';
::std::cout << decode( typeid( (*ff) ).name() )<< '\n'; }
Using the GNU Compiler Collection (GCC)
https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc.pdf
// always inline function x:
__attribute__ ((always_inline))
// never inline function x:
__attribute__ ((noinline))
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
void example( void )
{
#warning Function "test" is not yet implemented, use -Werror
}