Skip to main content
Filter by
Sorted by
Tagged with
Advice
0 votes
4 replies
184 views

Title: Why does GCC transform a >= 4 into a > 3 at -O0? JG seems more complex than JGE I'm analyzing a simple C code on godbolt and found GCC's code generation puzzling: long a; a = a >= 4; ...
Alexandr's user avatar
Best practices
2 votes
10 replies
288 views

In C, when I pass a pointer to a function, the compiler always seems to assume that the data pointed to by that pointer might be continuously modified in another thread, even though in actual API ...
Moi5t's user avatar
  • 465
11 votes
1 answer
619 views

Consider the following simplified code: template <class T> class Foo { T t; const T* t_ptr; public: constexpr Foo(T t): t(t), t_ptr(&this->t) {} constexpr Foo(const Foo&...
eyelash's user avatar
  • 4,126
1 vote
2 answers
149 views

Take the below piece of code, that simply Trims a string, removing whitespace characters from either end: const std::string TrimString(const std::string& s) { const auto iter = std::find_if(s....
The Welder's user avatar
  • 1,099
3 votes
2 answers
105 views

I have an application where I need to generate date and time based on the locale using the strftime function provided by C's time.h: #include <stdio.h> #include <time.h> #include <...
Micro Soft's user avatar
Advice
0 votes
8 replies
144 views

I recently learned about C23's implementation for #embed, so I was wondering if I can use that with extern in a c++23 program/game to have all 3d models and assets baked into the exe but not in memory ...
jade22's user avatar
  • 13
3 votes
2 answers
190 views

I have two functions counting the occurrences of a target char in the given input buffer. The functions vary only in how they communicate the result back to the caller; one returns the result and the ...
Devashish's user avatar
  • 193
Tooling
0 votes
3 replies
98 views

Which IDE and tools are best suited for gcc C development? I currently use vscode and the tried using the ms-vscode.cpptools extension which "supports" gcc C. But extensions like nested ...
mcmah309's user avatar
3 votes
1 answer
119 views

I stumbled upon different behavior of std::filesystem::path::parent_path() when a path contains leading slashes. Clang says that the parent of ///a is /// (which is what I would expect), but GCC says ...
danpla's user avatar
  • 705
Advice
2 votes
6 replies
121 views

Does anyone know if there is, in c++, any way to determine at runtime the cpu characteristics of the machine that compiled the code? For example, in gcc (which I'm using) the preprocessor variable ...
user3195869's user avatar
6 votes
0 answers
143 views

I was experimenting with some fixed-point arithmetic on the Cortex-M0+ in Godbolt's compiler explorer and came across an interesting behaviour with respect to the optimisation of a multiplication ...
Simon's user avatar
  • 664
4 votes
1 answer
95 views

Looking at this benchmark about a custom std::function implementation: https://github.com/PacktPublishing/Hands-On-Design-Patterns-with-CPP-Second-Edition/blob/main/Chapter06/09_function.C I tried to ...
luczzz's user avatar
  • 446
Advice
0 votes
6 replies
80 views

I have a AVR GCC toolchain compiled to work on aarch64-linux-gnu devices (ARM64) and it produced twice larger file (around 35Kb) than almost identical command-line on desktop (mac silicon, around 20Kb)...
4ntoine's user avatar
  • 20.6k
0 votes
1 answer
105 views

I'm trying to build, using CMake, a program involving C++ and CUDA-C++ code. It used to build file, several months ago, but - now am getting a linker error I'm not familiar with: in function `main....
einpoklum's user avatar
  • 137k
0 votes
2 answers
84 views

I'm on Windows OS and in the past month I used to compile a C/C++ project in Qt Creator IDE using MinGW's gcc/g++ compilers based on POSIX thread model, i.e. compilers that were built with the option -...
ahahfilip's user avatar
1 vote
0 answers
88 views

I am making my own UNIX like OS called Connor's UNIX and I am implementing kernel and userspace separation and I have been all day and this is as far as I can get it to work and if you need any more ...
Connor Thomson's user avatar
1 vote
0 answers
90 views

The following code compiles in gcc15 with g++ -std=c++17 #include <iostream> int main() { int A, B; std::cin >> A >> B; auto v = std::tie(A, B); } However, this is ...
EJam's user avatar
  • 389
-1 votes
0 answers
67 views

I'm following the barebones guide on OSDev Wiki and I'm trying to compile my kernel.c file with i686-elf-gcc -ffreestanding -O2 -m32 -c kernel.c -o kernel.o but I constantly get the following ...
James Cho's user avatar
0 votes
1 answer
54 views

I disassembled a 7,838,304-Byte portion of /usr/lib/x86_64-linux-gnu/dri/i965_dri.so using Capstone as shown below: #include <stdio.h> #include <string.h> #include <stdint.h> #...
TheAhmad's user avatar
  • 940
0 votes
1 answer
52 views

I try to build some source code containig Win32 API code with GCC 8.3.0 (i686-posix-dwarf) that comes with Strawberry Perl Portable package. It easily builds code, but struggles when it comes to ...
DLWHI's user avatar
  • 145
1 vote
0 answers
54 views

I need to install RStan and I want to make sure that it's as efficient as possible. I'm using gcc. I'm reading this guide from 2022. Luckily, the Stan developers built an option called STAN_CPP_OPTIMS ...
AnthonyC's user avatar
  • 705
2 votes
0 answers
44 views

Regardless of --build or --target, when configure points out the I'm trying to compile GNU pth in 32-bits form under Linux. Toolchain used: Ubuntu 24.04.2 (VM) gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13....
Marc St-Jacques's user avatar
Advice
0 votes
1 replies
42 views

Disclaimer: I'm expecting that the answer to this question will be that it can't be done, but I'm asking as a just in case. I am working on a JIT'd language with the compiler and runtime implemented ...
idka's user avatar
  • 131
0 votes
0 answers
40 views

For -std=c17 (and higher) DW_AT_language is C11: $ echo "int x;" | gcc -c -xc - -fPIC -o x.o -g -std=c17 $ gcc -shared -o x.so x.o $ readelf x.so -w | grep -P '(DW_AT_language\s*:|DWARF ...
pmor's user avatar
  • 6,757
0 votes
1 answer
20 views

I have a program targeting a small memory ARM R5 CPU, being compiled with gcc 11.2.0 and ld 2.37.20210721. I have a critical symbol that I would like to know the address of, even if the binary was ...
Seth Robertson's user avatar
Tooling
0 votes
0 replies
42 views

A friend of mine has an application in C he has been helping to maintain, which he has been building for Linux, but he asked me to help build Windows binaries. The project has a Makefile.win32, so it ...
CalicoSkies's user avatar