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
22
votes
8 answers

Compile multiple C source fles into a unique object file

I have some C source files and I am using gcc. I basically want to compile all of them and create one single object file. When I try: gcc -c src1.c src2.c src3.c -o final.o I get: gcc: cannot specify -o with -c or -S with multiple files If I…
Andry
  • 16,172
  • 27
  • 138
  • 246
22
votes
3 answers

Error: command 'gcc' failed: No such file or directory

I'm trying to run a python setup.py build --compiler=mingw32 but it results in the error mentioned in the subject: error: command 'gcc' failed: No such file or directory but I am capable of running gcc from command prompt (i have added it to my…
sihrc
  • 2,728
  • 2
  • 22
  • 43
22
votes
3 answers

Why does GCC not warn for unreachable code?

Why doesn't GCC (4.6.3) give me any warning for the unreachable code in the below example? #include int status(void) { static int first_time = 1; if (first_time) { return 1; first_time = 0; /* Never reached */ …
Andreas Haas
  • 221
  • 2
  • 4
22
votes
2 answers

How can I dump an abstract syntax tree generated by gcc into a .dot file?

I think the question's title is self-explanatory, I want to dump an abstract syntax tree generated by gcc into a .dot file (Those files generated by Graphviz) because then I want to view it in a .png file or similar. Is there any way I can do that?
asdrubalivan
  • 1,149
  • 2
  • 9
  • 17
22
votes
2 answers

Are these comments about GCC's optimisations valid?

At the bottom of Demystifying the Restrict Keyword is this curious advice: Due to the order in which scheduling is done in GCC, it is always better to simplify expressions. Do not mix memory access with calculations. The code can be re-written as…
spraff
  • 32,570
  • 22
  • 121
  • 229
22
votes
3 answers

How to find out which optimizations are actually applied when using gcc?

With IBM's XL compiler family it is possible to supply two options (-qreport and -qlist) to generate reports for each source file that include information on which optimizations were applied, or which parts of the code could not be optimized (and…
22
votes
3 answers

(Missing) performance improvements with C++11 move semantics

I've been writing C++11 code for quite some time now, and haven't done any benchmarking of it, only expecting things like vector operations to "just be faster" now with move semantics. So when actually benchmarking with GCC 4.7.2 and clang 3.0…
gustaf r
  • 1,224
  • 9
  • 14
22
votes
1 answer

Variadic template as template parameter: deduction works with GCC but not with Clang

While compiling some C++11 code with both GCC 4.7.2 and Clang 3.1, I ran into a problem with Clang not managing to deduce a template argument where GCC succeeds. In a more abstract form, the code looks like this: src/test.cc: struct Element…
psyill
  • 891
  • 6
  • 10
22
votes
3 answers

Does the C programming language have a runtime?

Objective-C has a runtime that translates its syntax into functions that are organized and compiled. Does C have a runtime library? Also, if anyone can answer the question, what are the steps GCC takes during C compilation? e.g. main.c >> main.s >>…
George Morgan
  • 669
  • 10
  • 23
22
votes
19 answers

gcc-4.2 failed with exit code 1 iphone

I've seen this error with different variations on discussion forums but being a non programmer I'm not sure how to progress this. Basically I have code which I found to help me with changing the background colors of cells on a grouped uitableview.…
SKayser
  • 351
  • 1
  • 3
  • 6
22
votes
1 answer

When __builtin_memcpy is replaced with libc's memcpy

There is a version of C99/posix memcpy function in GCC: __builtin_memcpy. Sometimes it can be replaced by GCC to inline version of memcpy and in other cases it is replaced by call to libc's memcpy. E.g. it was noted here: Finally, on a compiler…
osgx
  • 90,338
  • 53
  • 357
  • 513
22
votes
1 answer

GDB examine memory permissions

I've an address in memory and I want to find out the permissions (r/w/x) of that memory address. E.g. char *s = "hello"; Here, the string literal "hello" is stored in read-only memory. When running the program through gdb, is there a possibility to…
viji
  • 2,706
  • 5
  • 28
  • 34
22
votes
6 answers

Is there any way to compile additional code at runtime in C or C++?

Here is what I want to do: Run a program and initialize some data structures. Then compile additional code that can access/modify the existing data structures. Repeat step 2 as needed. I want to be able to do this with both C and C++ using gcc…
Matt
  • 21,026
  • 18
  • 63
  • 115
21
votes
3 answers

Make gcc put relative filenames in debug information

The project I'm compiling uses CMake, which loves absolute pathnames. When I compile with debugging information enabled, gcc puts those long names into .debug_str sections, which is bad for debugging. I'd like to have short relative-to-project-root…
drdaeman
  • 11,159
  • 7
  • 59
  • 104
21
votes
1 answer

Strange C/C++ syntax

Possible Duplicate: What's this C++ syntax that puts a brace-surrounded block where an expression is expected? I've just come across this strange C/C++ syntax: #include int main() { printf("%s", ({ static char…
enobayram
  • 4,650
  • 23
  • 36