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
21
votes
2 answers

What is the difference in gcc between lto and fat-lto-objects

I have tried to compile to assembler my source code with next flags: 1. -flto 2. -flto -ffat-lto-objects 3. -flto -fno-fat-lto-objects Third one provides optimized slim LTO code as written in documentation, but I don't see any difference in the…
Laser
  • 6,652
  • 8
  • 54
  • 85
21
votes
2 answers

What are "extended integer types"?

Quoting from the book I'm reading: signed char, signed short int, signed int, signed long int, signed long long int are called standard signed integer types unsigned char, unsigned short int, unsigned int, unsigned long int, unsigned long long…
claws
  • 52,236
  • 58
  • 146
  • 195
21
votes
5 answers

error: cuda_runtime.h: No such file or directory

How can I force gcc to look in /usr/cuda/local/include for cuda_runtime.h? I'm attempting to compile a CUDA application with a C wrapper. I'm running Ubuntu 10.04. I've successfully compiled my CUDA application into a .so with the following…
skrieder
  • 379
  • 1
  • 2
  • 8
21
votes
3 answers

gcc: Reduce libc required version

I am trying to run a newly compiled binary on some oldish 32bits RedHat distribution. The binary is compiled C (not++) on a CentOS 32bits VM running libc v2.12. RedHat complains about libc version: error while loading shared libraries: requires…
MonoThreaded
  • 11,429
  • 12
  • 71
  • 102
21
votes
2 answers

Overload resolution behaviour difference between GCC and clang (SFINAE)

GCC accepts the following code: template struct meta { typedef typename T::type type; }; struct S {}; template typename meta::type foo(T, S); int foo(int, int); int main() { foo(0, 0); } But clang…
HighCommander4
  • 50,428
  • 24
  • 122
  • 194
21
votes
6 answers

In C++, is it bad to pass a const bool by reference?

In a practical environment, using gcc or MS Visual Studio, is it bad to pass the value types which are the same size or less than an int by const reference ? i.e. is it bad to write such a function: void f(const bool& b); or void f(const char&…
BlueTrin
  • 9,610
  • 12
  • 49
  • 78
21
votes
4 answers

Why is this program's output different between C and C++?

Possible Duplicate: Size of character ('a') in C/C++ The following program #include int main() { printf("%d\n", sizeof('\0')); printf("%d\n", sizeof(0)); } compiled with gcc outputs 4 4 and with g++ 1 4 Why is this…
Gabi
  • 600
  • 2
  • 13
21
votes
2 answers

cannot declare variable ‘’ to be of abstract type ‘’

EDIT: After spending a bit of time understanding the code I wrote I still don't know what is wrong with it. This is the base class from which I derived my class: ///ContactResultCallback is used to report contact points struct …
SteveDeFacto
  • 1,317
  • 4
  • 19
  • 35
21
votes
2 answers

Compiling and Linking GTK 3 with C project on Ubuntu

I believe this is not a duplicate question, I have seen all questions/answers before I post this question. I think I have a different situation here. I use Ubuntu 12.04 and downloaded GTK 2 and 3. I have copied a simple GTK source code from GNOME's…
Anwar
  • 4,470
  • 4
  • 24
  • 30
21
votes
2 answers

Disable "if(0)" elimination in gcc

How can I prevent GCC from eliminating the code inside if(0) block? When I use Visual Studio, one of my debugging techniques is to put code like this in my program: if (0) do_some_debug_printing_and_checking(); Then, when a breakpoint is hit, I…
Ivan Shcherbakov
  • 2,063
  • 14
  • 23
21
votes
4 answers

Catching assert() with side effects

We have several moderately sized C code bases that receive commits from developers with a variety of experience levels. Some of the less disciplined programmers commit assert() statements with side effects that cause bugs with assertions disabled.…
user221137
21
votes
3 answers

Typesafe varargs in C with gcc

Many times I want a function to receive a variable number of arguments, terminated by NULL, for instance #define push(stack_t stack, ...) _push(__VARARG__, NULL); func _push(stack_t stack, char *s, ...) { va_list args; va_start(args, s); …
mikebloch
  • 1,577
  • 11
  • 21
21
votes
2 answers

What does -lm option do in g++?

What does -lm option do in g++ and when is it needed? Is there a complete description of g++ options?
a-z
  • 1,634
  • 4
  • 16
  • 35
20
votes
3 answers

gcc Woverloaded-virtual warnings

The following C++ code i think is correct, but produce some warnings when compiled with "-Woverloaded-virtual", is the warning bogus or there is a real problem with this code? If that is a bogus warning what can i do to avoid it, define all the…
José
  • 3,041
  • 8
  • 37
  • 58
20
votes
2 answers

How fast is thread local variable access on Linux

How fast is accessing a thread local variables in Linux. From the code generated by the gcc compiler, I can see that is uses the fs segment register. So apparently, the access to the thread local variable should not cost extra cycles. However, I…
pythonic
  • 20,589
  • 43
  • 136
  • 219