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
20
votes
1 answer

gcc differences between -O3 vs -Ofast optimizations

I was just reading through the gcc manual to find out the difference between -O3 and -Ofast. For -O3 -O3 Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the following optimization flags: -fgcse-after-reload…
user8469759
  • 2,522
  • 6
  • 26
  • 50
20
votes
2 answers

How to build MinGW W64

I'm new to Stack Overflow, C++ and to MinGW W64. My problem is, is that I don't know how to build MinGW W64, all I know how to do is double click an exe and install the files onto my computer itself. So what I am asking is that, how do you build…
Robert
  • 201
  • 1
  • 2
  • 4
20
votes
6 answers

Strange zero initialization with g++

I came across on a strange behavior of the following code, while playing around with initialization of ints using g++ 4.4.3. int main() { int x(int()); int y = int(); cout << x << " " << y << endl; } the…
Slavcho Ivanov
  • 244
  • 1
  • 5
20
votes
7 answers

Unable to see elements of std::vector with gcc in VS code

I'm currently using VS Code to learn C++ because it was easy to setup and is much lighter than VS Studio. However, one thing that I'm unable to do is to see the elements of an array (or string, etc), in debug mode. I've searched for solutions here,…
tomas-silveira
  • 593
  • 3
  • 5
  • 14
20
votes
2 answers

How to simulate printf's %p format when using std::cout?

unsigned char *teta = ....; ... printf("data at %p\n", teta); // prints 0xXXXXXXXX How can I print variable address using iostreams? Is there a std::??? feature like std::hex to do this kind of conversion (address -> string), so std::cout <<…
kagali-san
  • 2,964
  • 7
  • 48
  • 87
20
votes
1 answer

Virtual function overloading in diamond hierarchy produces different results in clang and gcc

The following code produces different results on clang. #include struct Dummy1 {}; struct Dummy2 {}; struct A { virtual void foo(Dummy1) { std::cout << "A" << std::endl; } virtual void foo(Dummy2) { std::cout…
breiker
  • 226
  • 1
  • 7
20
votes
3 answers

How to install GCC/G++ 8 on CentOS

I'm used to install packages on Debian/Ubuntu distributions, but now I need to install gcc and g++ version 8.*. There is only version 4.* in CentOS repositories. What's the correct way to install them manually?
Eenoku
  • 2,741
  • 4
  • 32
  • 64
20
votes
6 answers

Any way to disable `tempnam' is dangerous, better use `mkstemp' gcc warning?

I'm using tempnam() only to get the directory name, so this security warning does not apply to my case. How can I disable it? I couldn't find any switches to do it.
jackhab
  • 17,128
  • 37
  • 99
  • 136
20
votes
2 answers

What are my available march/mtune options?

Is there a way to get gcc to output the available -march=arch options? I'm getting build errors (tried -march=x86_64) and I don't know what my options are. The compiler I'm using is a proprietary wrapper around gcc that doesn't seem to like…
Brydon Gibson
  • 1,179
  • 3
  • 11
  • 22
20
votes
5 answers

dyld: Library not loaded: /usr/local/lib/libmpfr.4.dylib

When I run "make" on a project I get this error: dyld: Library not loaded: /usr/local/lib/libmpfr.4.dylib Referenced from: /Users/Petrov/Downloads/mips/bin/../libexec/gcc/mipsel-elf/4.8.1/cc1 Reason: image not found There is no libmpfr.4.dylib…
Elizabeth Haker
  • 301
  • 1
  • 2
  • 3
20
votes
3 answers

Undefined behavior from pointer math on a C++ array

Why the output of this program is 4? #include int main() { short A[] = {1, 2, 3, 4, 5, 6}; std::cout << *(short*)((char*)A + 7) << std::endl; return 0; } From my understanding, on x86 little endian system, where char has 1…
Jacek Skiba
  • 251
  • 1
  • 8
20
votes
2 answers

How to start writing a PHP5 extension in C++

I'm writing a PHP5 extension, and while I could write it in C, it would be easier to use C++ and take advantage of the STL and Boost. Trouble is, the tutorials I've seen only deal with C, and I'm looking for a basic example which uses C++ Here's…
Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
20
votes
2 answers

How to make gcc warn undefined struct?

I have a struct defined in .h struct buf_stats { // *** }; then in .c file struct buf_stats *bs = malloc(sizeof(struct buf_states*)) ; where buf_states is a typo. but gcc does not warn me, although I used -Wall and this bug/typo cost me 3 hours…
Sato
  • 8,192
  • 17
  • 60
  • 115
20
votes
6 answers

Warnings or errors for C++ implicit conversion of primitives

I've done some heavy refactoring of some C++ code, and discovered numerous bugs arising from implicit conversions that I'm not aware of. Example struct A *a(); bool b() { return a(); } void c() { int64_t const d(b()); } Issues In b, the…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
20
votes
2 answers

Cython Install GCC error

Trying to install Cython on a small VPS running Ubuntu Server. Did sudo apt-get install gcc and then python setup.py install In the Cython directory, but I get this peculiar error. running install running build running build_py running…
DizzyDoo
  • 1,489
  • 6
  • 21
  • 32