New answers tagged gcc
0 votes
How to use GCC with Microsoft Visual Studio?
Install MSYS2. Install GCC by MSYS2 MSYS shell by running the following commands. pacman -Syu pacman -S --needed base-devel mingw-w64-x86_64-toolchain Add these directories to the system environment ...
0 votes
Compiling C and C++ files together using GCC
As mentioned in a couple of comments by Gabriel Devillers (1, 2), you could use g++ en lieu of gcc for a one-liner, by using -x c and then specifying the .c files afterwards, like so: g++ -std=c++0x -...
0 votes
Why does GCC compiled code fail on modifying a thread_local std::deque?
Try light compiler optimization -Og In my environment, I see a crash with uninitialized std::deque memory when CMAKE_BUILD_TYPE=Debug . No crash is observed when building with CMAKE_BUILD_TYPE=...
0 votes
Accepted
error: ‘format’ attribute argument 3 value ‘7’ does not refer to a variable argument list
I posted it in GCC Bugzilla. The short answer is: format does not work with variable templates type. It only works with variable argument list. The documentation should make this clear. I found for ...
5 votes
Accepted
Why does ARM GCC push / pop scratch register R3 in a tiny function?
This is probably for stack alignment. The AAPCS calling conventions require 8-byte stack alignment at a "public interface", which means on entry to a function. So the stack pointer must ...
2 votes
Why doesn't GCC on Linux produce "undefined reference to `__gcov_xxx'" (while GCC on Windows does)?
Part of answer by user Brecht Sanders: Also, on Windows you can't build shared libraries (.dll) or executables (.exe) with unresolved symbols. Part of "DLL hell" is that you must make sure ...
1 vote
Accepted
Why does impure_data still exist with GCC -fno-math-errno
Specifying -nostdlib -lc fixed the issue whether -g is provided or not. The assumption is that these options replace libg.a with libc.a, allowing the -fno_math_errno option to be considered. As to why ...
Community wiki
0 votes
GCC left shift overflow
For right shift, it would be safe to write division instead. I would assume that if there is a sufficient instruction, compiler would optimise it out anyway, replacing with a platform specific ...
0 votes
Is there a 128 bit integer in gcc?
Starting with C23, you can use the _BitInt(128) and unsigned _BitInt(128) types for signed and unsigned 128-bit integers, respectively. However, these types are not mandatory; they only exist if ...
Advice
0 votes
0 replies
0 views
gcc: "SET_TYPE_STRUCTURAL_EQUALITY"
I passed (essentially) my question to the AI Assistant in the new interface to Stack Overflow. This was VERY helpful. Thank you. Jørgen
0 votes
How to get GCC to inline strcpy (string copy)
Another option - which can be relevant for the cases that the actual strcpy are for short string, and the benefits of the avoiding the calls is significant - is to implement "light weight" ...
0 votes
How to get GCC to inline strcpy (string copy)
For string of unknown length - inlining strcpy can be complex - different strategies can optimized for different cases (long string, vs short string, different architecture, ...) It's easier to get ...
1 vote
Is there a direct way to get clear details on gcc acceptable option values (e.g. for -std) without grep-ing through irrelevant material?
gcc and g++ don't offer an option to list available standards, but there is a nice trick to get them all. Type g++ -std= in a terminal and press tab, and it will list available options: $ g++ -std= c++...
Advice
0 votes
0 replies
0 views
Advice
0 votes
0 replies
0 views
gcc: "SET_TYPE_STRUCTURAL_EQUALITY"
A simple, real-life example would probably help a lot.
Advice
0 votes
0 replies
0 views
gcc: "SET_TYPE_STRUCTURAL_EQUALITY"
Additional info: The term 'macro' is used in various descriptions of similar directives, so I tried to see if the mentioned could be used literally, but GCC's preprocessor took it for an ordinary name....
Advice
0 votes
0 replies
0 views
3 votes
Accepted
Resolving circular dependency in modules
Remove unnecessary #include and forward declarations from header files. Add #include to those files only that miss identifiers. #endif of include guards must be last lines. Constants in header files ...
1 vote
Accepted
Can't get my custom context switch working with arm inline assembly
The problem was caused because I made the PSP register point at the task stack. This caused data corruption, and the processor couldn't switch to the tasks. Instead of pointing at the task stack, I ...
1 vote
-Wextra-semi is not supported in gcc?
-Wextra-semi was added to GCC in major-version 8; its documentation was moved to C++ Dialect Options. It is available in all newer versions of GCC (latest I could check at time of writing is 15.2).
Advice
0 votes
0 replies
0 views
G++ Not recognizing .bin file as input
omg im dumb lol. Sorry I'm super new to all this. Thank you!
Advice
0 votes
0 replies
0 views
G++ Not recognizing .bin file as input
If you trying to compile mippsim.cpp, you don't need the .bin file. If you are trying to run mippsim, you don't need g++. Having both g++ and the .bin file in the same command doesn't make much sense. ...
2 votes
How do I call "cpuid" in Linux?
With GCC there is no need to invoke cpuid from inline assembler, because it provides the __get_cpuid_count() and __get_cpuid() intrinsics via cpuid.h. __get_cpuid_count() is more generic as it also ...
Tooling
0 votes
0 replies
0 views
How can I get a truly portable GCC toolchain with multilib support that runs on any Linux distribution without system dependencies?
@ValdikSS Thanks for the suggestions! I actually built a solution that addresses the portability limitation you mentioned—it's truly distribution-agnostic and relocatable. I've posted the details in ...
Tooling
0 votes
0 replies
0 views
How can I get a truly portable GCC toolchain with multilib support that runs on any Linux distribution without system dependencies?
Yes, it's possible to create a truly portable GCC toolchain. After weeks of trial and error, countless build failures, and debugging mysterious linker errors, I finally figured out how to build ...
0 votes
GNU linker script - how to automatically distribute code to multiple dis-contiguous sections
Credit to @KamilCuk for identifying my duplicate question and suggesting a way to achieve what I, and by the sound of it you, want to achieve (he has declined to respond to my suggestion he post it as ...
Advice
0 votes
0 replies
0 views
How can I use gcc linker (for 'C' code) to automatically fit variables around reserved addresses
FYI, I've had success with the following algorithm: Compile all translation units into object files. Have a fake memory contiguous memory layout to link into to get a good estimate of the final ...
Tooling
0 votes
0 replies
0 views
How can I get a truly portable GCC toolchain with multilib support that runs on any Linux distribution without system dependencies?
Take a look at how e.g. Linaro toolchain is built: https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads It doesn't have any path requirements. I believe crosstool-ng also builds path-...
1 vote
Accepted
Compiler errors related to avx512 when upgrading from Eigen 3.4.0 to 5.0.0 on x86-64 RHEL cluster
The compiler you are using doesn't have support for that intrinsic, which began appearing in Eigen in the 5.0 release series. For GCC, support was added in the GCC 10 series. For Clang, it appears to ...
Top 50 recent answers are included
Related Tags
gcc × 42298c × 16008
c++ × 13659
linux × 5262
assembly × 2625
clang × 2319
linker × 2176
g++ × 2095
makefile × 1821
c++11 × 1685
arm × 1525
macos × 1339
compilation × 1189
mingw × 1084
x86 × 1065
ld × 1035
windows × 925
compiler-errors × 870
optimization × 847
inline-assembly × 836
python × 820
cmake × 813
ubuntu × 795
cross-compiling × 782
x86-64 × 731