Questions tagged [gcc]

GCC is the GNU Compiler Collection. It's the de facto standard compiler for C, C++, Go, Fortran, and Ada on Linux and supports many other languages and platforms as well.

GCC is the GNU Compiler Collection, a collection of free software compilers. It is a key component of the GNU Toolchain.

GCC includes an optimizing C compiler that is the most commonly used C compiler on Linux. GCC also includes front ends for C++ (including full support for C++17), Objective-C, Fortran, Ada, and Go, as well as libraries for these languages (libstdc++, libgfortran, ...). It supports many architectures.

GCC sources are available via the Git repository. Major decisions about GCC are made by the steering committee, guided by the mission statement.

See also GCC online documentation and the home page, and release dates.

40905 questions
167
votes
3 answers

How does #include work in C++?

I have read from a codeforces blog that if we add #include in a C++ program then there is no need to include any other header files. How does #include work and is it ok to use it instead of including individual header…
GorvGoyl
  • 42,508
  • 29
  • 229
  • 225
165
votes
10 answers

How to suppress GCC warnings from library headers?

I have a project that uses log4cxx, boost, etc. libraries whose headers generate lots of (repetitive) warnings. Is there a way to suppress warnings from library includes (i.e. #include ) or includes from certain paths? I'd like to use…
AdSR
  • 2,097
  • 3
  • 15
  • 9
165
votes
1 answer

What are the differences between -std=c++11 and -std=gnu++11?

What are the differences between -std=c++11 and -std=gnu++11 as compilation parameter for gcc and clang? Same question with c99 and gnu99? I know about C++ and C standards, it's the differences in the parameters that interest me. I've read somewhere…
Klaim
  • 67,274
  • 36
  • 133
  • 188
162
votes
6 answers

Static link of shared library function in gcc

How can I link a shared library function statically in gcc?
suresh
  • 4,084
  • 10
  • 44
  • 59
162
votes
9 answers

How can I tell gcc not to inline a function?

Say I have this small function in a source file static void foo() {} and I build an optimized version of my binary yet I don't want this function inlined (for optimization purposes). is there a macro I can add in a source code to prevent the…
vehomzzz
  • 42,832
  • 72
  • 186
  • 216
161
votes
5 answers

What is the difference between C, C99, ANSI C and GNU C?

I have started programming practice on codechef and have been confused by the difference between C and C99. What does C mean here? Is it C89? Check the languages at the bottom of this submit. It contains both C and C99. I found on the internet…
Aseem Bansal
  • 6,722
  • 13
  • 46
  • 84
161
votes
3 answers

Difference between CC, gcc and g++?

What are the difference between the 3 compilers CC, gcc, g++ when compiling C and C++ code in terms of assembly code generation, available libraries, language features, etc.?
vehomzzz
  • 42,832
  • 72
  • 186
  • 216
157
votes
4 answers

What is the use of _start() in C?

I learned from my colleague that one can write and execute a C program without writing a main() function. It can be done like this: my_main.c /* Compile this with gcc -nostartfiles */ #include void _start() { int ret = my_main(); …
SimpleGuy
  • 2,764
  • 5
  • 28
  • 45
156
votes
3 answers

Difference between -pthread and -lpthread while compiling

What is the difference between gcc -pthread and gcc -lpthread which is used while compiling multithreaded programs?
Vishnuraj V
  • 2,819
  • 3
  • 19
  • 23
153
votes
2 answers

GCC -g vs -g3 GDB Flag: What is the Difference?

When compiling C source code with either gcc or Clang, I always use the -g flag to generate debugging information for gdb. gcc -g -o helloworld helloworld.c I noticed that some people recommend -g3 instead. What is the difference between the -g and…
haziz
  • 12,994
  • 16
  • 54
  • 75
152
votes
11 answers

Compile error: "g++: error trying to exec 'cc1plus': execvp: No such file or directory"

When I compile C/C++ program with popen in php... I got this error: g++: error trying to exec 'cc1plus': execvp: No such file or directory but if I run php code in shell.. it works fine.. in Arch Linux.. PHP Code:
Zeyi Fan
  • 2,213
  • 3
  • 17
  • 19
152
votes
7 answers

What does the fpermissive flag do?

I'm just wondering what the -fpermissive flag does in the g++ compiler? I am getting: error: taking address of temporary [-fpermissive] which I can solve by giving the -fpermissive flag to the compiler. EDIT: I just found what was causing the…
mmirzadeh
  • 6,893
  • 8
  • 36
  • 47
151
votes
13 answers

How to remove unused C/C++ symbols with GCC and ld?

I need to optimize the size of my executable severely (ARM development) and I noticed that in my current build scheme (gcc + ld) unused symbols are not getting stripped. The usage of the arm-strip --strip-unneeded for the resulting executables /…
Yippie-Ki-Yay
  • 22,026
  • 26
  • 90
  • 148
151
votes
3 answers

LLVM vs clang on OS X

I have a question concerning llvm, clang, and gcc on OS X. What is the difference between the llvm-gcc 4.2, llvm 2.0 and clang? I know that they all build on llvm but how are they different? Besides faster compiling, what is the advantage of llvm…
dominik
  • 5,745
  • 6
  • 34
  • 45
149
votes
1 answer

Bubble sort slower with -O3 than -O2 with GCC

I made a bubble sort implementation in C, and was testing its performance when I noticed that the -O3 flag made it run even slower than no flags at all! Meanwhile -O2 was making it run a lot faster as expected. Without optimisations: time ./sort…
anon
  • 1,269
  • 2
  • 4
  • 6