Skip to main content
Filter by
Sorted by
Tagged with
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> #...
19 votes
9 answers
26k views

GCC compiler gives me the following macros: __FILE__ so that I can print out the file name + directory. __LINE__ so that I can print out the line number of where I'm printing from. __PRETTY_FUNCTION__ ...
11 votes
1 answer
620 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&...
10 votes
1 answer
2k views

According to http://gcc.gnu.org/wiki/Visibility, With -fvisibility=hidden, you are telling GCC that every declaration not explicitly marked with a visibility attribute has a hidden visibility. And ...
1 vote
0 answers
55 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 ...
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 ...
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 <...
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; ...
-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 ...
35 votes
5 answers
35k views

Related questions How can I detect the operating system in C/C++? How can I find out what operating system I am running under in GCC or in ANSI C? I'd be fine If I can know if I'm running on POSIX. ...
8 votes
1 answer
10k views

I'm trying to get gcc's ld to ignore unresolved references when putting together a shared library from a bunch of object files compiled with -fpic flag. I tried a bunch of options so far such as (...
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....
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 ...
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 ...
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 ...
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 ...
13 votes
3 answers
19k views

I want to compile part of my code only on x86 and x86_64 linux, but not s390 linux or others. How to use the macro define in C to achieve it? I know linux is to determine linux OS, and 386, 486 and ...
3 votes
3 answers
670 views

I would like to do the following: std::string b = "b"; is_in("a", { "a", "b", "c" }); is_in("d", { "a", "b", "c&...
15 votes
1 answer
10k views

Why glibc and pthread library both defined same APIs ? Here is the snapshot ubuntu@ubuntu:/lib$ objdump -T /lib/i386-linux-gnu/libc.so.6 |grep pthread_cond_signal 000f8360 g DF .text 00000039 ...
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)...
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 ...
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....
2 votes
1 answer
9k views

i know that there are some other posts with this problem but the solutions that where given weren't helpful for me. I just installed MinGW on my Windows 7 laptop. So i wrote a hello world program to ...
0 votes
2 answers
2k views

I'm attempting to install the cs50 library https://manual.cs50.net/library/#mac_os so that I can compile c code for the class on my OS X 10.10.1. Unfortunately, I'm having some problems. Let me walk ...
6 votes
1 answer
12k views

I've read everything here and everything I can find on the net about doing this, but the information is out-of-date, contradictory, or inapplicable. I have a very simple library in C, which I compile ...
18 votes
5 answers
9k views

I know how to use __attribute__((deprecated)) or [[deprecated]] to deprecate a function like this: int old_fn() __attribute__ ((deprecated)); [[deprecated]] int old_fn2(); But how to deprecate a ...
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 -...
0 votes
2 answers
148 views

If I use gcc -std=c17, will -Wpedantic issue warnings for C17? Is this the same as ISO C?
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 ...
11 votes
2 answers
15k views

Or - who is "stricter"? From what I've read, both flags add extra warnings, not included in '-Wall', but what distinguish them?
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 ...
2 votes
1 answer
2k views

I am trying to make changes to the openMP runtime library (GOMP). As far as I know, the library comes with GCC compiler but my goal is to work on GOMP alone. So I wonder how I can build and develop ...
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....
3 votes
2 answers
570 views

I wonder if there's some clever, automatic way of knowing if a particular compiler warning (e.g. -Wunused-parameter) comes from the group -Wall, -Wextra, or another group, for both GCC and Clang. Use ...
17 votes
3 answers
4k views

Consider the following example: #include <iostream> int main () { int i = 0; #pragma omp parallel { #pragma omp critical { ++i; } } std:...
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 ...
1 vote
2 answers
2k views

gcc / g++ throws exit code 1 and does nothing I tried to compile my c++ / c files using gcc / g++ ! It did nothing the command neither produced a.exe file it didn't throw any error ,(print anything ...
1 vote
2 answers
151 views

I want to write a code in C language to output a list of triples matching the Pythagorean triple in a range of positive integers (a2 = b2 + c2 with a, b and c ∈ ℤ+) using only nested while () loops. I ...
12 votes
4 answers
9k views

I'm using GCC 9.2.0 on both an ancient Linux (RedHat 5.2) and modern macOS 10.14.6 Mojave, and I get the same complaint on both. #include <stdio.h> #include <time.h> struct Example { ...
18 votes
3 answers
2k views

When I compile the following simple recursion code with g++, the assembly code simply returns i, as if g++ can do some algebra tricks as humans can. int Identity(int i) { if (i == 1) return 1; ...
0 votes
1 answer
143 views

In chasing down a very opaque bug, I have been trying to compile with no warnings or errors. This part of my code worked fine, but gcc complains about the braces; it says there are braces missing and ...
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 ...
1 vote
1 answer
914 views

I am trying to migrate code from older gcc (7.5.0) to newer 11.3.0. All working, tested code, but I am not able to get rid of some warnings (I use -Werror) like: warning: ‘free’ called on pointer ‘...
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 ...
80 votes
12 answers
208k views

I am programming the host side of a host-accelerator system. The host runs on the PC under Ubuntu Linux and communicates with the embedded hardware via a USB connection. The communication is performed ...
11 votes
2 answers
6k views

I am using some logging macros, which are supposed to print out the information provided by the __PRETTY_FUNCTION__ macro and if needed name and value of up to two arguments. A simplified version of ...
Advice
2 votes
10 replies
395 views

I'm a small-scale C programmer at the moment, and I'm bugged by the question: is Visual Studio worth the annoyance that it is? I've been programming in C and C++ in Visual Studio Code for a while, and ...
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 ...
5 votes
1 answer
143 views

I came across a strange problem. I made a C++20 module with the following content (file module.cppm): module; #include <regex> #include <string> export module foo; export namespace bar { ...
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 ...

1
2 3 4 5
846