undefined reference issue with latest gcc
I have link-time error when trying to compile following code with gcc 12.1.0.With clang, msvc and older gcc it compiles as expected.template<typename T>void def(){}template<void (*foobar)() =...
View ArticleGCC MIPS - Unknown Register Name $8 for Inline Assembly
I have some inline assembly code which is producing some errors.__asm__ volatile ("move $8,%0" ::"r"(addr):"$8","memory");This produces an error which is "unknown register name '$8'". It's also talking...
View ArticleWhy does the final output is rounding off itself?
In the code below, #include <stdio.h> float area(float var) { return (var*var); } int main() { float side; printf("\nEnter the side of square : "); scanf("%f",&side); **printf("The area is :...
View ArticleWhy is GCC subtracting 1 and comparing
I was writing some code to clear the screen to a particular color. C++ code:void clear_screen(unsigned int color, void *memory, int height, int width) { unsigned int *pixel = (unsigned int *)memory;...
View ArticleGCC Compile SSE code: undefined reference to `__mm_prefetch`
I am trying to use _mm_prefetch() function. from here, I thought it was from SSE. when I compile it with gcc7.3.1, I do like follows:gcc -std=c11 -msse -msse2 -mfpmath=sse -O3 -fopenmp MyApp.c But it...
View ArticleHow do I build a C++ image for aarch64-none-elf
Some background:I'm writing a bare-metal C++ app/OS for the Raspberry Pi 4B (in 64-bit mode, so booting kernel8.elf off of an SD card) and I've been running into strange crashes/hangs (where logging to...
View ArticleHow many GCC optimization levels are there?
How many GCC optimization levels are there?I tried gcc -O1, gcc -O2, gcc -O3, and gcc -O4If I use a really large number, it won't work.However, I have triedgcc -O100and it compiled.How many...
View ArticleSystem function overloading in nested shared library
Simple scenarioApplication uses write function from libc and links to shared library.Shared library defines write function.Original write function from libc will be overloaded by its version from the...
View ArticleWhat are analogs of FreeBSD functions cgetfirst(), cgetnext(), cgetstr() in...
I am trying to port old C code from FreeBSD into Ubuntu. The code contains calls to some functions specific for old FreeBSD C-standard library (stdlib.h). What are the analogs of these functions in...
View ArticleHow can I differentiate, in my C/C++ code, between GCC and clang as the...
I usually write GCC-targeted code by checking __GNUC__. Now I want to write some code which behaves differently for GCC and for clang - but it seems clang defines __GNUC__ as well. How do I...
View Articleusr/x86_64-unknown-linux-gnu/bin/ld: cannot find -lbsd
A little background for the problem I am having:I just migrated from Ubuntu Focal Fossa to Mint Cinnamon keeping my home in a partitionlibbsd is installed and can be used to compile some test code (I...
View Articlestd::regex constructor throwing std::regex_error with what(): regex_error
I need to get some strings from a given line as below:{"username":"wrongpass", "password":"abc", "email":"example@gmail.com"}To be more specific, those in "" are needed. Here is my code:#include...
View ArticleCan't build Qt-Widgets Application using CMake
I am trying to setup a CMake Project building a Qt-Widgets application but can't compile it properly. My project structure is as...
View Articlehow to build a GO program using github.com/AllenDang/giu and...
When I try to build a Go program which uses 'github.com/gordonklaus/portaudio' and 'github.com/AllenDang/giu' I got C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running x86_64-w64-mingw32-g++...
View ArticleError while using GFortran on Mac: "ld: library not found for -lm"
When running a python "case" file for a computational/simulation program (used in research) via the command line on my MacBook (Big Sur 11.5) I get the following error:ld: library not found for...
View ArticleGCC -Wdangling-pointer correct or bug?
I ran into some code that builds a linked list on the stack and via destructors cleans up correctly AFAICTCode:#include <iostream>#include <sstream>template <typename T>struct...
View ArticleHow can I compile a c++ file which depends on multiple 3rd party headers...
I have a c++ file test_arb.cpp#include "arb.h"int main(){ //some code}I run like this:I found arb calls flint so I uncluded both arb and flint like this :g++ -c -I"C:/Users\hp/Documents/Projects/arb"...
View ArticleHow can I install gcc to my cotex A55 platform?
I now have a cortex-A55 embedded board and I want to run some python scripts on it .However when I install dependency for the py scripts ,the setup.py program prints that there is no available gcc on...
View ArticleGeneral protection fault when setting up IDT for hobby OS
I am currently writing a toy operating system, and I have been having this issue for a while now. When setting up the IDT for a hobby OS, and triggering an interrupt, the interrupt at first happens...
View Article__builtin_sinf What is it? Where is it? How do I obtain the dissassembly of it?
I was curious this morning to see if I could obtian and understand the machine instructions generated for calculating a mathematical function such as sin, which as far as I am aware there is no machine...
View Article