Why do we need both read and write barriers?
Why do we need to define two types of barriers with the same implementation?For example, this code from io_uring in Linux:#if defined(__x86_64) || defined(__i386__)#define read_barrier() __asm__...
View ArticleMSVC produces faster c++ code than g++ on Windows [closed]
I am currently working on a C++ project on Windows. It is computationally expensive involving a lot of random numbers generation and calculation of special math functions (e.g. gamma).Code compiled...
View ArticleC Macro is not expanded within Macro
I am developing a application which interact with hardware with ioctls. I wrote some lower level api for performing device operations. I wrote some macros as wrappers. as following.WRITE_REGISTER(99,...
View ArticleMakefile: how to specify library name at the end of command using patsubst
I am new to Makefile, C and Linux. I am using gcc & ubuntu. I encountered a problem while trying to compile the code with a link to a library. Here is my problem. I have: a_tests.c & b_tests.c...
View ArticleCross compile modern C++ from Linux to Windows
I have some modern C++ sources (C++17, say) and I have no problem compiling complex source base on Linux for Linux 32/64, and on Windows for Windows 32/64 using mingw-w64 (from msys2).Now I want to...
View Articlevscode problem matcher issues when using WSL to build on cmd.exe
I am writing code in WSL using a remote session and then building on cmd.exe. The build process works fine but I cannot get the problem matcher to link to the correct files. I change my cwd "options":...
View ArticleGCC fatal error: stdio.h: No such file or directory
I'm trying to compile a program in C on OS X 10.9 with GCC 4.9 (experimental). For some reason, I'm getting the following error at compile time:gcc: fatal error: stdio.h: No such file or directoryI...
View ArticleGCC automatically grouping variable and code sections
My linux C project has a simple makefile which compiles and links several modules.I can see in the output.map that variables and functions are being linked on an as they are declared basis, module by...
View ArticleHow to install gcc/g++ 9 on CentOS 8 docker (centos:latest)
In order to use the C++17 include <filesystem> I need gcc-9 package in my centos docker.By default centos:latest (aka 8) will install gcc 8.3.1 from the regular distro repo.Is there any PPA,...
View ArticleOptimal code for creating this mask with intrinsics?
This is related to, but distinct from, this question:How to clear the upper 128 bits of __m256 value?Let me start with what I believe to be the "correct" intrinsics code.__m256i mask(){ return...
View ArticlePrinting array of integers generates weird output in Ada
I created a simple Ada program that allows a user to populate an array with a maximum of 100 non negative and non zero integers and then prints them out. When I call the function to print out the...
View ArticleHow can I figure out why function has segmentation fault
My other functions that I have used in this program works upon execution just fine but this method has a segmentation fault core dump occurring after a few seconds of it being loaded. Can anyone...
View ArticleHow to only process the macros in a C/C++ project without compiling it?
I'm trying to review a C/C++ project which is heavily dealing with macros and function-like macros. What I would like to do is to replace the define and function-like macros with their replacement.For...
View ArticleWhy does gcc generates strange code without flag -fno-pie?
I am trying to compile dummy function in gcc with flag -fno-pie and without.void dummy_test_entrypoint() { }When i compile without the flag.gcc -m32 -ffreestanding -c test.c -o test.oI get the...
View ArticleWhat are .LFB .LBB .LBE .LVL .loc in the compiler generated assembly code
When I look into the assembly code generated by GCC, there are many lines begining with .LBB and a number. It seems to that they are not instructions of operations. More like marking something of the...
View ArticleGCC: Building cross-compiler for ARM - pthread.h not found
Using a Ubuntu 12.04 host, I carefully followed this SO answer here (Recipe for Compiling Binutils and GCC Together) to build GCC and binutils in one tree with all of their dependencies.Here is the...
View ArticleHow do I designate which compiler is called when running cmake + make?
I'm trying to compile a c++ project with cmake and make on OSX but it looks like make is using CXX or clang when I want to use g++ (gcc) so I can follow the answer here to tell the compiler where to...
View ArticleAVR-GCC Windows vs. Linux
I'm working on an Arduino project which was being developed on a Windows machine with the Arduino Builder. After having a release candidate, I started developing a Linux docker container that would...
View Articlebuild 32-bit code on 64-bit linux system (kubuntu 18.04)
I'm looking into porting a 32-bit AIX app to linux - doing proof of concept on my 64-bit Kubuntu desktop system. I suppose I could build the app in 64-bit mode, but I'm afraid stuff might break (there...
View Articlegcc options when creating .so for JNI
I have a question regarding an article of JNI at http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html.gcc -o libnativelib.so -shared -Wl,-soname,libnative.so...
View Article