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
2296
votes
12 answers

Why doesn't GCC optimize a*a*a*a*a*a to (a*a*a)*(a*a*a)?

I am doing some numerical optimization on a scientific application. One thing I noticed is that GCC will optimize the call pow(a,2) by compiling it into a*a, but the call pow(a,6) is not optimized and will actually call the library function pow,…
xis
  • 24,330
  • 9
  • 43
  • 59
1797
votes
35 answers

fatal error: Python.h: No such file or directory

I am trying to build a shared library using a C extension file but first I have to generate the output file using the command below: gcc -Wall utilsmodule.c -o Utilc After executing the command, I get this error message: > utilsmodule.c:1:20: fatal…
Mohanad Y.
  • 18,278
  • 3
  • 12
  • 12
1618
votes
23 answers

Compiling an application for use in highly radioactive environments

We are compiling an embedded C++ application that is deployed in a shielded device in an environment bombarded with ionizing radiation. We are using GCC and cross-compiling for ARM. When deployed, our application generates some erroneous data and…
rook
  • 66,304
  • 38
  • 162
  • 239
1145
votes
10 answers

What is the difference between g++ and gcc?

What is the difference between g++ and gcc? Which one of them should be used for general c++ development?
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
1105
votes
5 answers

Why does the C preprocessor interpret the word "linux" as the constant "1"?

Why does the C preprocessor in GCC interpret the word linux (small letters) as the constant 1? test.c: #include int main(void) { int linux = 5; return 0; } Result of $ gcc -E test.c (stop after the preprocessing…
ahmedaly50
  • 7,765
  • 3
  • 12
  • 7
795
votes
2 answers

Why is my program slow when looping over exactly 8192 elements?

Here is the extract from the program in question. The matrix img[][] has the size SIZE×SIZE, and is initialized at: img[j][i] = 2 * j + i Then, you make a matrix res[][], and each field in here is made to be the average of the 9 fields around it in…
anon
687
votes
31 answers

How to automatically generate a stacktrace when my program crashes

I am working on Linux with the GCC compiler. When my C++ program crashes I would like it to automatically generate a stacktrace. My program is being run by many different users and it also runs on Linux, Windows and Macintosh (all versions are…
KPexEA
  • 16,560
  • 16
  • 61
  • 78
608
votes
11 answers

How do I list the symbols in a .so file

How do I list the symbols being exported from a .so file? If possible, I'd also like to know their source (e.g. if they are pulled in from a static library). I'm using gcc 4.0.2, if that makes a difference.
Moe
  • 28,607
  • 10
  • 51
  • 67
581
votes
14 answers

Convert char to int in C and C++

How do I convert a char to an int in C and C++?
mainajaved
  • 7,905
  • 10
  • 36
  • 44
577
votes
5 answers

GCC -fPIC option

I have read about GCC's Options for Code Generation Conventions, but could not understand what "Generate position-independent code (PIC)" does. Please give an example to explain me what does it mean.
Narek
  • 38,779
  • 79
  • 233
  • 389
571
votes
9 answers

Why does the order in which libraries are linked sometimes cause errors in GCC?

Why does the order in which libraries are linked sometimes cause errors in GCC?
Landon
  • 15,166
  • 12
  • 37
  • 30
567
votes
6 answers

Debug vs Release in CMake

In a GCC compiled project, How do I run CMake for each target type (debug/release)? How do I specify debug and release C/C++ flags using CMake? How do I express that the main executable will be compiled with g++ and one nested library with gcc?
Cartesius00
  • 23,584
  • 43
  • 124
  • 195
554
votes
7 answers

What exactly is LLVM?

I keep hearing about LLVM all the time. It's in Perl, then it's in Haskell, then someone uses it in some other language? What is it? What exactly distinguishes it from GCC (perspectives = safety etc.)?
bodacydo
  • 75,521
  • 93
  • 229
  • 319
533
votes
21 answers

Undefined reference to vtable

When building my C++ program, I'm getting the error message undefined reference to 'vtable... What is the cause of this problem? How do I fix it? It so happens that I'm getting the error for the following code (The class in question is…
RyanG
  • 6,773
  • 5
  • 25
  • 24
523
votes
17 answers

How do you get assembler output from C/C++ source in GCC?

How does one do this? If I want to analyze how something is getting compiled, how would I get the emitted assembly code?
Doug T.
  • 64,223
  • 27
  • 138
  • 202
1
2 3
99 100