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

GCC 9.1 returns void& as result type for an explicit destructor call. Is this a bug?

I'm trying to get this is-class-defined-check to work, which relies on the fact that decltype(std::declval().~Foo()) is void if Foo has a destructor (which it has if it is defined…) and is ill-formed otherwise, invoking SFINAE in this…
Lukas Barth
  • 2,734
  • 18
  • 43
21
votes
3 answers

gcc warning: function used but not defined

I am getting the warning: function used but not defined. I have static __inline__ in header file say a.h. The header file is included in a.c. I would like put all those inline function which are in header files into the .c files. Following code…
thetna
  • 6,903
  • 26
  • 79
  • 113
21
votes
2 answers

How to correctly reference a function in an anonymous namespace

Consider this fragment of C++ code: namespace { void f() { } class A { void f() { ::f(); // VC++: error C2039: 'f' : is not a member of '`global namespace'' } }; } GCC compiles this just…
detunized
  • 15,059
  • 3
  • 48
  • 64
21
votes
1 answer

Why is 0 == ("abcde"+1) not a constant expression?

Why doesn't the following code compile? // source.cpp int main() { constexpr bool result = (0 == ("abcde"+1)); } The compile command: $ g++ -std=c++14 -c source.cpp The output: source.cpp: In function ‘int main()’: source.cpp:4:32: error:…
embedc
  • 1,485
  • 1
  • 6
  • 20
21
votes
3 answers

Why does clang still need libgcc.a to compile my code?

int main(int argc, char **argv) { return 0; } I cross compile (host= linux x86_64, target= linux aarch64) /path/to/clang --target=aarch64-linux-gnu -v main.cpp -o main -fuse-ld=lld -L./libs -lc -lc_nonshared -Xlinker -Map=a.map In the -L./libs…
robor
  • 2,969
  • 2
  • 31
  • 48
21
votes
3 answers

GCC vs MS C++ compiler for maintaining API backwards binary compatibility

I came from the Linux world and know a lot of articles about maintaining backwards binary compatibility (BC) of a dynamic library API written in C++ language. One of them is "Policies/Binary Compatibility Issues With C++" based on the Itanium C++…
linuxbuild
  • 15,843
  • 6
  • 60
  • 87
21
votes
6 answers

unable to execute 'x86_64-conda_cos6-linux-gnu-gcc': No such file or directory (pysam installation)

I am trying to install pysam. After excecuting: python path/to/pysam-master/setup.py build This error is produced: unable to execute 'x86_64-conda_cos6-linux-gnu-gcc': No such file or directory error: command 'x86_64-conda_cos6-linux-gnu-gcc'…
Sergio.pv
  • 1,380
  • 4
  • 14
  • 23
21
votes
2 answers

No small string optimization with gcc?

Most std::string implementations (GCC included) use small string optimization. E.g. there's an answer discussing this. Today, I decided to check at what point a string in a code I compile gets moved to the heap. To my surprise, my test code seems to…
SU3
  • 5,064
  • 3
  • 35
  • 66
21
votes
2 answers

Why does including break structured bindings in GCC?

Consider: struct Point { int x, y; }; int main() { const auto [x, y] = Point{}; } This code compiles fine with gcc 7.1 in C++17 mode, however this one: #include struct Point { int x, y; }; int main() { const auto [x, y] =…
robson3.14
  • 3,028
  • 2
  • 20
  • 19
21
votes
3 answers

Warning C4996: This function or variable may be unsafe -- compared to GCC on POSIX

I notice that MS compilers give "deprecated" warnings for cstdlib functions like getenv. MS has invented its own standard such as _dupenv_s. Question 1 AFAIK the main "unsafe" thing is about reentrancy *. Since MS's CRT is marked as "multi-threaded"…
kizzx2
  • 18,775
  • 14
  • 76
  • 83
21
votes
2 answers

Incremental linking using gcc on linux. Is it possible?

The way my team's project is developed, we generate a Shared Object library for our application from all all of our .o object files. My task (hopefully it is specific enough but also general enough to be of use to others!) is to link in only the…
Raphael Raven
  • 213
  • 2
  • 5
21
votes
2 answers

how to select a particular gcc-toolchain in clang?

Clang automatically selects the gcc-version with the highest version: $ clang++ -v main.cpp clang version 3.8.1-12 (tags/RELEASE_381/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation:…
Gaetano
  • 1,090
  • 1
  • 9
  • 25
21
votes
2 answers

How to vectorize with gcc?

The v4 series of the gcc compiler can automatically vectorize loops using the SIMD processor on some modern CPUs, such as the AMD Athlon or Intel Pentium/Core chips. How is this done?
21
votes
2 answers

strcpy_s not working with gcc

I have a C++11 project, and I added some strcpy_s method calls. This works on windows, but when compiling on gcc, there is an error stating that strcpy_s symbol is not found. I did add the line #define __STDC_WANT_LIB_EXT1__ 1 to the code, to no…
Jacko
  • 12,665
  • 18
  • 75
  • 126
21
votes
3 answers

Disable all optimization options in GCC

The default optimization level for compiling C programs using GCC is -O0. which turns off all optimizations according to GCC documentation. for example: gcc -O0 test.c However, to check if -O0 is really turning off all optimizations. I…
staticx
  • 1,201
  • 2
  • 16
  • 31