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

The difference between -pedantic-errors and -Werror=pedantic in gcc

What is the difference between using -pedantic-errors and -Werror=pedantic in gcc? According to the documentation of GCC there is a difference: -pedantic-errors Give an error whenever the base standard (see -Wpedantic) requires a diagnostic, in…
Supremum
  • 542
  • 7
  • 23
20
votes
1 answer

g++ compilation error "... is protected from within this context" while there's no error with clang

I have the following code: #include class BaseClass { protected: static int x; }; int BaseClass::x; class DerivedA: public BaseClass { public: DerivedA() { x = 3; } }; class DerivedB: public BaseClass { …
Timo
  • 1,724
  • 14
  • 36
20
votes
3 answers

How to change optimization level of one function?

This is related to Determine cause of segfault when using -O3? In the question, I'm catching a segfault in a particular function when compiled with -O3 using a particular version of GCC. At -O3, vectorization instructions are used (at -O2, they are…
jww
  • 97,681
  • 90
  • 411
  • 885
20
votes
1 answer

What does gcc without multilib mean?

I was trying to use the omh.h header file and I realized it was missing. I tried reinstalling gcc on my mac using brew. This is the message I got at the end of the installation. .. GCC has been built with multilib support. Notably, OpenMP may not…
Pranjal Mittal
  • 10,772
  • 18
  • 74
  • 99
20
votes
7 answers

gcc -Wshadow is too strict?

In the following example: class A { public: int len(); void setLen(int len) { len_ = len; } // warning at this line private: int len_; }; gcc with -Wshadow issue a warning: main.cpp:4: warning: declaration of `len' shadows a member…
dimba
  • 26,717
  • 34
  • 141
  • 196
20
votes
1 answer

GCC with -Werror and -Wno-error=unused does not work as expected

I always compile with -Wall -Wextra -Werror. However, many times as I do quick compile tests I need to ignore the -Wunused suite of errors. For various reasons, I want to see them as warnings and not errors while leaving all other warnings as…
bolov
  • 72,283
  • 15
  • 145
  • 224
20
votes
1 answer

MinGW doesn't produce warnings

I have successfully installed MinGW on a Windows 7 32bit machine, and have tried to compile a simple program using either the command line or the MinGW console. The code has an intentional error in a printf statement: #include #include…
2501
  • 25,460
  • 4
  • 47
  • 87
20
votes
6 answers

Why do I get "cast from pointer to integer of different size" error?

The following line (pure c) compiles cleanly on windows (win7 64 bits + codeblocks 13 + mingw32) and debian (wheezy 32 bits + codeblocks 10 + gcc) but raises warning on kali (64 bits + codeblocks + gcc). Any comments? I mean, why do I get this…
ssd
  • 2,340
  • 5
  • 19
  • 37
20
votes
2 answers

Is it feasible for GCC to optimize isnan(x) || isnan(y) into isunordered(x, y)?

Here's my code: int f(double x, double y) { return std::isnan(x) || std::isnan(y); } If you're using C instead of C++, just replace std:: with __builtin_ (don't simply remove std::, for reasons shown here: Why does GCC implement isnan() more…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
20
votes
3 answers

Auto-vectorizing: Convincing the compiler that alias check is not necessary

I am doing some image processing, for which I benefit from vectorization. I have a function that vectorizes ok, but for which I am not able to convince the compiler that the input and output buffer have no overlap, and so no alias checking is…
Antonio
  • 19,451
  • 13
  • 99
  • 197
20
votes
2 answers

Weird GCC array initialization behavior

I encountered a variant of this code when looking at another question (the original code used a std::thread instead of std::vector, but the syntax is the same): #include #include #include #include int…
T.C.
  • 133,968
  • 17
  • 288
  • 421
20
votes
3 answers

Compiling Phalcon - Virtual memory exhausted: Cannot allocate memory

When I try to compile Phalcon, I get an error: virtual memory exhausted: Cannot allocate memory I am running the following commands git clone --depth=1 git://github.com/phalcon/cphalcon.git cd cphalcon/build sudo ./install I have a VPS with 1GB…
Nikolaos Dimopoulos
  • 11,495
  • 6
  • 39
  • 67
20
votes
7 answers

Unknown type name ‘off64_t’

I have a problem using Apache Portable Runtime on Ubuntu with GCC 4.8.1 The problem is that the off64_t from is not available when compiling with gcc. (When compiling with g++ everything work fine) Does anybody know which compiler…
Der Appit
  • 329
  • 1
  • 2
  • 4
20
votes
2 answers

gcc with parameters "-S -save-temps" puts intermediate files in current directory

The parameters -S -save-temps work fine, as long as i don't use them on files with the same name. Think of the following situation: I have a project with a main directory and a subdirectory with the name subDir and in both of the directories are…
Customizer
  • 665
  • 2
  • 7
  • 20
20
votes
1 answer

How do I get a homebrewed version of GDB working on Mac OS X?

I am trying to debug a C++ program in Eclipse using gdb. I think it works fine in my main() function, but elsewhere it gives me a warning when I try to look at the value of a variable: Failed to execute MI command: -data-evaluate-expression…
Neal Kruis
  • 2,055
  • 3
  • 26
  • 49