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
126
votes
11 answers

How do I fix "for loop initial declaration used outside C99 mode" GCC error?

I'm trying to solve the 3n+1 problem and I have a for loop that looks like this: for(int i = low; i <= high; ++i) { res = runalg(i); if (res > highestres) { highestres…
The.Anti.9
  • 43,474
  • 48
  • 123
  • 161
126
votes
7 answers

How can I compile without warnings being treated as errors?

The problem is that the same code that compiles well on Windows, is unable to compile on Ubuntu. Every time I get this error: cc1: warnings being treated as errors Now, it's big code base and I don't like fix all the warnings. Is there a way I can…
Saurabh Verma
  • 6,328
  • 12
  • 52
  • 84
125
votes
16 answers

Static assert in C

How can compile-time static asserts be implemented in C (not C++), with particular emphasis on GCC?
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
125
votes
6 answers

experimental::filesystem linker error

I try to use the new c++1z features actually on the head of development within gcc 6.0. If I try this little example: #include #include namespace fs = std::experimental::filesystem; int main() { fs::path p1 =…
Klaus
  • 24,205
  • 7
  • 58
  • 113
123
votes
5 answers

What is the difference between gcc -ggdb and gcc -g

When I use gcc to compile C programs I usually use -g to get some debug information into the elf file so that gdb can help me if needed. However, I noticed that some programs use -ggdb, since it's supposed to make the debug info more gdb friendly.…
Johan
  • 20,067
  • 28
  • 92
  • 110
121
votes
5 answers

how to install gcc on windows 7 machine?

I have MinGW on my windows 7 machine. I wish to install and use complete gcc for C compiler. I found there is no single pre-compiled ready-made installation file for this purpose. I checked the following page : http://gcc.gnu.org/install/ It is…
KawaiKx
  • 9,558
  • 19
  • 72
  • 111
121
votes
4 answers

Is cout synchronized/thread-safe?

In general I assume that streams are not synchronized, it is up to the user to do appropriate locking. However, do things like cout get special treatment in the standard library? That is, if multiple threads are writing to cout can they corrupt the…
edA-qa mort-ora-y
  • 30,295
  • 39
  • 137
  • 267
121
votes
5 answers

GCC fatal error: stdio.h: No such file or directory

I'm trying to compile a program in C on OS X 10.9 with GCC 4.9 (experimental). For some reason, I'm getting the following error at compile time: gcc: fatal error: stdio.h: No such file or directory I then tried a simple Hello World…
Jules
  • 14,200
  • 13
  • 56
  • 101
121
votes
1 answer

Member initialization while using delegated constructor

I've started trying out the C++11 standard and i found this question which describes how to call your ctor from another ctor in the same class to avoid having a init method or the like. Now i'm trying the same thing with code that looks like…
lfxgroove
  • 3,778
  • 2
  • 23
  • 33
120
votes
4 answers

What does -D_XOPEN_SOURCE do/mean?

I recently encountered some code that gcc would not compile without this arg. I checked the gcc man page, but did not find this specific option. I did find XOPEN_SOURCE, but there was little explanation of what it does. Can someone please elaborate?…
anio
  • 8,903
  • 7
  • 35
  • 53
120
votes
12 answers

Using pre-compiled headers with CMake

I have seen a few (old) posts on the 'net about hacking together some support for pre-compiled headers in CMake. They all seem a bit all-over the place and everyone has their own way of doing it. What is the best way of doing it currently?
Glutinous
  • 1,201
  • 2
  • 9
  • 3
119
votes
8 answers

How to change the default GCC compiler in Ubuntu?

I have installed gcc-3.3/g++-3.3 on ubuntu 11.04 which already has gcc/g++-4.4. So in my system both gcc-3.3 and 4.4 are available. I am able to call both compilers as I want. If I just call the command gcc then gcc-4.4 will get called. To call…
RoboAlex
  • 4,895
  • 6
  • 31
  • 37
119
votes
9 answers

How did I get a value larger than 8 bits in size from an 8-bit integer?

I tracked down an extremely nasty bug hiding behind this little gem. I am aware that per the C++ spec, signed overflows are undefined behavior, but only when the overflow occurs when the value is extended to bit-width sizeof(int). As I understand…
Unsigned
  • 9,640
  • 4
  • 43
  • 72
118
votes
3 answers

gcc/g++: "No such file or directory"

g++ gives me errors of the form: foo.cc::: fatal error: : No such file or directory compilation terminated. It is the same when compiling C-programs with gcc. Why is that? Please note: This question has been asked many times…
Sebastian Mach
  • 38,570
  • 8
  • 95
  • 130
118
votes
1 answer

Ask GDB to list all functions in a program

How can you list all functions in a program with GDB?
pythonic
  • 20,589
  • 43
  • 136
  • 219