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
5 answers

iostream vs ostream what is different?

As the book says (Exploring C++: The Programmer's Introduction to C++): The istream header declares input operators (>>), and ostream declares output operators(<<). I can perfectly run the code without adding #include : #include…
Mustafa Ekici
  • 7,263
  • 9
  • 55
  • 75
21
votes
5 answers

why is char's sign-ness not defined in C?

The C standard states: ISO/IEC 9899:1999, 6.2.5.15 (p. 49) The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and…
Elazar Leibovich
  • 32,750
  • 33
  • 122
  • 169
21
votes
5 answers

How do modern compilers use mmx/3dnow/sse instructions?

I've been reading up on the x86 instruction set extensions, and they only seem useful in some quite specific circumstances (eg HADDPD - (Horizontal-Add-Packed-Double) in SSE3). These require a certain register layout that needs to be either…
thecoop
  • 45,220
  • 19
  • 132
  • 189
21
votes
5 answers

c math linker problems on Ubuntu 11.10

Some strange error appeared after I upgraded my Ubuntu from (10.11, 11.04 i dont know) to 11.10. I am getting an undefined reference to 'sqrt' while using math.h and linking with -lm I'm compiling with gcc -Wall -Werror -g -Iinclude/ -lm…
Hachi
  • 3,237
  • 1
  • 21
  • 29
21
votes
2 answers

What sense do these clobbered variable warnings make?

I have a function like this: #include jmp_buf buf; void func2(int g); extern int some_global; void func(int x) { if (setjmp(buf)) return; if (some_global) x += 5; func2(x); } GCC (gcc (Debian 4.4.5-8) 4.4.5)…
Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
21
votes
4 answers

Inhibit default library paths with gcc

Is there a way to inhibit the default library path search with gcc? -nostdinc does this for the include path search, but -nostdlib, either by omission or by design, only inhibits the -lc -lgcc etc. but not the library search paths.
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
21
votes
2 answers

Android NDK: how to let gcc to use additional include directories

A simple question (i am using android NDK r6 with cygwin, but this is a question regarding makefiles and gcc). Suppose that i put under jni/ directory a library under the dir mylib_v_1/. Mylib is structured as: mylib_v_1 mylib …
Luke
  • 641
  • 3
  • 8
  • 14
21
votes
2 answers

How to correctly use a simple linker script? Executable gets SIGKILL when run

I'm trying to understand deeper linking process and linker scripts...looking at binutils doc i found a simple linker script implementation that i've improved by adding some commands: OUTPUT_FORMAT("elf32-i386", "elf32-i386", …
MirkoBanchi
  • 2,173
  • 5
  • 35
  • 52
21
votes
5 answers

Meaning of gcc -O2

I see this flag a lot in the makefiles. What does it mean and when should it be used?
Sasha
21
votes
2 answers

Debugging GCC compile times

I'm creating a fairly large library in C++0x using GCC 4.6 in Linux. My library relies heavily on template classes, resulting in long compile times for applications which use the library. I would like to start speeding things up by providing…
rcv
  • 6,078
  • 9
  • 43
  • 63
21
votes
1 answer

How to install GCC and GDB for WSL(windows subsytem for linux)?

I need gcc to compile a c code and unable to install gcc on wsl. I tried sudo apt-get install gcc but it doesn't work. This is the error. hack@DESKTOP-VMQA3JB:~$ sudo apt-get install gcc Reading package lists... Done Building dependency tree Reading…
21
votes
2 answers

How does the lambda macro create a lambda?

I found this piece of code on GitHub but didn't quite understand it: #define lambda(ret_type, _body) ({ ret_type _ _body _; }) Then: int (*max)(int, int) = lambda(int, (int x, int y) { …
Kish
  • 293
  • 1
  • 6
21
votes
1 answer

Why does GCC aggregate initialization of an array fill the whole thing with zeros first, including non-zero elements?

Why does gcc fill the whole array with zeros instead of only the remaining 96 integers? The non-zero initializers are all at the start of the array. void *sink; void bar() { int a[100]{1,2,3,4}; sink = a; // a escapes the…
Lassie
  • 853
  • 8
  • 18
21
votes
1 answer

Does the order of -l and -L options in the GNU linker matter?

The -l option tells the linker to search the libraries in the standard dirs. And with -L, we can specify our own library directories for searching. Question: Does the sequence of order matters for the -L option too, like it does for the -l w.r.t the…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
21
votes
2 answers

Should a definition inside template class be instantiated if it is not used?

template struct A { static constexpr T obj {}; static constexpr bool noexcept_copy = noexcept( T{obj} ); static void UsesCopy() { T{obj}; } static constexpr int C = 1; }; struct NoCopy { constexpr NoCopy() =…
anton_rh
  • 8,226
  • 7
  • 45
  • 73