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
313
votes
4 answers

I don't understand -Wl,-rpath -Wl,

For convenience I added the relevant manpages below. My (mis)understanding first: If I need to separate options with ,, that means that the second -Wl is not another option because it comes before , which means it is an argument to the -rpath…
Blub
  • 13,014
  • 18
  • 75
  • 102
310
votes
9 answers

How to disable GCC warnings for a few lines of code

In Visual C++, it's possible to use #pragma warning (disable: ...). Also I found that in GCC you can override per file compiler flags. How can I do this for "next line", or with push/pop semantics around areas of code using GCC?
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
301
votes
12 answers

Is bool a native C type?

I've noticed that the Linux kernel code uses bool, but I thought that bool was a C++ type. Is bool a standard C extension (e.g., ISO C90) or a GCC extension?
asussex
  • 3,051
  • 2
  • 16
  • 6
300
votes
6 answers

GCC dump preprocessor defines

Is there a way for gcc/g++ to dump its default preprocessor defines from the command line? I mean things like __GNUC__, __STDC__, and so on.
Anycorn
  • 50,217
  • 42
  • 167
  • 261
297
votes
9 answers

How to use/install gcc on Mac OS X 10.8 / Xcode 4.4

I have install Mountain Lion (Mac OS X 10.8) and now gcc doesn't seem to be available anymore. I've also installed Xcode 4.4 so there is no more /Developer directory. I need gcc both for mac ports and for ruby gems (that have native…
Athir Nuaimi
  • 3,214
  • 2
  • 14
  • 17
296
votes
4 answers

What is the order of evaluation in a member initializer list?

I have a constructor that takes some arguments. I had assumed that they were initialized in the order listed, but in one case, it appears they were being initialized in reverse, resulting in an abort. When I reversed the arguments, the program…
hookenz
  • 36,432
  • 45
  • 177
  • 286
292
votes
8 answers

What is makeinfo, and how do I get it?

I'm trying to build GNU grep, and when I run make, I get: [snip] /bin/bash: line 9: makeinfo: command not found What is makeinfo, and how do I get it? (This is Ubuntu, if it makes a difference)
mike
  • 46,876
  • 44
  • 102
  • 112
292
votes
7 answers

Clang vs GCC - which produces faster binaries?

I'm currently using GCC, but I discovered Clang recently and I'm pondering switching. There is one deciding factor though - quality (speed, memory footprint, reliability) of binaries it produces - if gcc -O3can produce a binary that runs 1% faster,…
SF.
  • 13,549
  • 14
  • 71
  • 107
284
votes
13 answers

Modulo operation with negative numbers

In a C program I was trying the below operations (Just to check the behavior) x = 5 % (-3); y = (-5) % (3); z = (-5) % (-3); printf("%d ,%d ,%d", x, y, z); It gave me output as (2, -2 , -2) in gcc. I was expecting a positive result every…
Alva
  • 2,882
  • 3
  • 14
  • 8
268
votes
15 answers

Can't install Ruby under Lion with RVM – GCC issues

Most questions regarding this problem are due to missing Xcode; I have Xcode 4.2 installed. Install attempt: rvm install 1.9.3 Installing Ruby from source to: /Users/jamie/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your…
Jamie Schembri
  • 6,047
  • 4
  • 25
  • 37
268
votes
5 answers

Why does GCC use multiplication by a strange number in implementing integer division?

I've been reading about div and mul assembly operations, and I decided to see them in action by writing a simple program in C: File division.c #include #include int main() { size_t i = 9; size_t j = i / 5; …
qiubit
  • 4,708
  • 6
  • 23
  • 37
268
votes
16 answers

libpthread.so.0: error adding symbols: DSO missing from command line

When I'm compiling openvswitch-1.5.0, I've encountered the following compile error: gcc -Wstrict-prototypes -Wall -Wno-sign-compare -Wpointer-arith -Wdeclaration-after-statement -Wformat-security -Wswitch-enum -Wunused-parameter…
jaeyong
  • 8,951
  • 14
  • 50
  • 63
267
votes
13 answers

How can I suppress "unused parameter" warnings in C?

For instance: Bool NullFunc(const struct timespec *when, const char *who) { return TRUE; } In C++ I was able to put a /*...*/ comment around the parameters. But not in C of course, where it gives me the error: error: parameter name omitted
nixgadget
  • 6,983
  • 16
  • 70
  • 103
254
votes
8 answers

How can I turn on (literally) ALL of GCC's warnings?

I would like to enable—literally—all of the warnings that GCC has. (You'd think it would be easy...) You'd think -Wall might do the trick, but nope! You still need -Wextra. You'd think -Wextra might do the trick, but nope! Not all of the warnings…
user541686
  • 205,094
  • 128
  • 528
  • 886
251
votes
7 answers

typedef fixed length array

I have to define a 24-bit data type.I am using char[3] to represent the type. Can I typedef char[3] to type24? I tried it in a code sample. I put typedef char[3] type24; in my header file. The compiler did not complain about it. But when I defined a…
341008
  • 9,862
  • 11
  • 52
  • 84