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

Linking Statically with glibc and libstdc++

I'm writing a cross-platform application which is not GNU GPL compatible. The major problem I'm currently facing is that the application is linked dynamically with glibc and libstdc++, and almost every new major update to the libraries are not…
themoondothshine
  • 2,983
  • 5
  • 24
  • 34
21
votes
2 answers

"CMAKE_CXX_COMPILER broken" while compiling with CMake

I'm trying to compile a Git project, and I'm facing some problems with CMake. Initially, it didn't find the C++ compiler and prompted an error: cmake .. No CMAKE_CXX_COMPILER could be found. Tell CMake where to find the compiler by setting either…
ptkato
  • 668
  • 1
  • 7
  • 14
21
votes
2 answers

Why does 'typeof enum constant' generate a warning when compared to a variable of enum type?

I have the following code. typedef enum {FOO, BAR} Baz; int main() { Baz f1 = FOO; typeof(FOO) f2 = FOO; return (f1 == f2); } My compilation using gcc -Wextra foo.c generates a warning saying foo.c: In function ‘main’: foo.c:7:13:…
kungjohan
  • 475
  • 4
  • 18
21
votes
2 answers

What does the "^@" mean in file?

Code: int fd; fd = open("fruit", O_WRONLY); write(fd, "apple", sizeof("apple")); close(fd); I compile it with $ gcc test.c -o test and run as $ ./test Then I open the fruit file, and I see the following in the file: apple^@ What does the ^@…
Ren
  • 2,852
  • 2
  • 23
  • 45
21
votes
2 answers

Compile a linux 2.6 kernel module with newer compiler

I build embedded machines that run an RT_PREMPT version of Linux. It's an Ubuntu 10.04 installation running an Linux 2.6 kernel. Yes, it's an old kernel, but I'm stuck with it for awhile. When I compiled the kernel, I used gcc version 4.4. On this…
user761576
  • 481
  • 2
  • 6
  • 15
21
votes
3 answers

Is there an offline MinGW installer?

I am learning C and I want to install MinGW on my laptop. The MinGW installer is a web-installer, it requires the computer to have access to the internet when installing. But the problem is that my computer's not connected to the internet. So it…
user4183195
21
votes
5 answers

How to print result of a compile-time calculation in C++?

I've wrote several constexpr functions and use them in static_asserts to control some resource limits. But I'd like to not only enforce compile-time predicate but also to see the actual values calculated during normal compilation process or at least…
Dmitry Vyal
  • 2,347
  • 2
  • 24
  • 24
21
votes
1 answer

Why can't I move std::ofstream?

Looking at previous answers on SO, it seems that while std::ostream is not be movable, std::ofstream should be. However, this code #include int main() { std::ofstream ofs; std::ofstream ofs2{std::move(ofs)}; } does not seem to…
toth
  • 2,519
  • 1
  • 15
  • 23
21
votes
7 answers

How to tell the MinGW linker not to export all symbols?

I'm building a Windows dynamic library using the MinGW toolchain. To build this library I'm statically linking to other 2 which offer an API and I have a .def file where I wrote the only symbol I want to be exported in my library. The problem is…
James R.
  • 213
  • 1
  • 2
  • 5
21
votes
1 answer

gcov warning: merge mismatch for summaries

Can anyone tell me what the gcov message "Merge mismatch for summaries" means? I have found the message in the gcc source here: http://www.opensource.apple.com/source/gcc/gcc-5646/gcc/libgcov.c It seems to be a sanity check that the tags in the…
mikelong
  • 3,694
  • 2
  • 35
  • 40
21
votes
3 answers

Why does enable_shared_from_this have a non-virtual destructor?

I have a pet project with which I experiment with new features of C++11. While I have experience with C, I'm fairly new to C++. To train myself into best practices, (besides reading a lot), I have enabled some strict compiler parameters (using GCC…
Stéphan Kochen
  • 19,513
  • 9
  • 61
  • 50
21
votes
1 answer

C++11 private default constructor

The following C++11 code compiles successfully on my GCC 4.8: struct NonStack { private: NonStack() = default; public: static NonStack* Create(){ return new NonStack; } }; NonStack a; int main() { } However the following gives a…
thomas
  • 505
  • 3
  • 12
21
votes
3 answers

How to prohibit the use of global variables on compile time

Is there a way to prohibit the use of global variables? I want GCC to generate an error on compile time when a global variable is defined. We have a code that should be run per thread and want to allow only use of stack (which is thread safe) Is…
Itay Marom
  • 801
  • 6
  • 15
21
votes
1 answer

Do C/C++ compilers such as GCC generally optimize modulo by a constant power of 2?

Let's say I have something like: #define SIZE 32 /* ... */ unsigned x; /* ... */ x %= SIZE; Would the x % 32 generally be reduced to x & 31 by most C/C++ compilers such as GCC?
Matt
  • 21,026
  • 18
  • 63
  • 115
21
votes
1 answer

How to deal with linker error - error - "cannot find -lgcc"

This is my makefile: task0 : main.o numbers.o add.o gcc -m32 -g -Wall -o task0 main.o numbers.o add.o main.o : main.c gcc -g -Wall -m32 -ansi -c -o main.c numbers.o : numbers.c gcc -g -Wall -m32 -ansi -c -o…
kitsuneFox
  • 1,243
  • 3
  • 18
  • 31