mingw - cdecl required to run functions correctly
The code below is running correctly with any online gcc compiler I found (gcc 9.2.0), it also run correctly with CYGWIN gcc compiler, but unfortunately it doesn't work well with MINGW gcc compiler -...
View ArticleHow to recompile with -fPIC
I was trying to reinstall my ffmpeg, following this guide, on my ARM Ubuntu machine. Unfortunately, when I compile a program which uses this lib I get the following failure:/usr/bin/ld:...
View ArticleWhy is gcc's right-shift code different in C and C++ mode?
When ARM gcc 9.2.1 is given command line options -O3 -xc++ -mcpu=cortex-m0 [compile as C++] and the following code:unsigned short adjust(unsigned short *p){ unsigned short temp = *p; temp -=...
View ArticleUnintended behavior of the "mov" instruction (loads wrong address)
During my journey of assembly language, I came across this strange behavior involving mov instruction.This unintended behavior is that the address I intended to load gets changed to the equivalent...
View ArticleWhen gcc acts on a text file, does it just see a series of machine code...
In anticipation of being eviscerated by more experienced and educated individuals, I just want to apologize for any "hand-wavey" or inaccurate phrasing that my following question is riddled with. I...
View ArticleCustom kernel not reading global variables and char*
I have a custom bootloader booting into a custom kernel. I'm writing in C now the assembly is out of the way.So far, local variables and methods work fine, but global variables aren't being recognized...
View ArticleGCC strange behavior under bad conversion specification [duplicate]
This is a simple code to check the behavior of GCC handling conversion specifications.(i know the warnings and so on, but i just play with the conversions)#include <stdio.h>int main(){ int i =...
View Article-pthread and OpenMP independently and implicitly affect the running time of...
I am trying to study the speed change with and without OpenMP.To do this, I wrote the following program:#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include...
View ArticleConverting a working code from double-precision to quadruple-precision: How...
I have a big, old, FORTRAN 77 code that has worked for many, many years with no problems.Double-precision is not enough anymore, so to convert to quadruple-precision I have:Replaced all occurrences of...
View ArticleCan GCC compile GIMPLE?
GIMPLE is one of internal representations in GCC system. It is possible to dump GIMPLE or any other internal representation via -fdump-* compiler argument. But is there any way to compile dumped GIMPLE...
View ArticleStatic link of shared library function in gcc
How can I link a shared library function statically in gcc?
View ArticleModulo division within switch statement giving errors with GCC, written in C...
#include <stdio.h>#include <math.h>int main(){ float num1, num2; char op; scanf("%f", &num1); scanf("%c", &op); scanf("%f", &num2); switch(op) { case '%': int n1 = num1; int n2...
View ArticleHow a variable sized array in C work internally?
I am trying to understand how a variable sized static array work internally:Following is a fixed size static array in C and its Assembly equivalent;int main(){int arr[2] = {3};}================main:...
View Articleundefined reference eeror [abi:cxx11] when using map and compiling with clang
I started working on a language parser and came across with undefined reference while I was using std::map<std::string, std::string>/usr/bin/ld:...
View ArticleChanging default compiler from clang to gnu gcc in termux
I want to set default compiler from clang to gcc in termux (android application).gcc isn't available in official repo so I used pointless community repo. But now I can't configure the termux to use gcc...
View ArticleHow to debug kernel code without running kernel?
I'm reading some kernel books, I want to debug the spinlock_t usage, and prepared the following demo code:////////////////////////////// demo/spinlock.c////////////////////////////#include...
View ArticleGCC cross-compiler for DOS gives a bunch of linker errors for "Hello world!"...
I've tried to configure GCC 9.3.0 to produce executable files for DOS. However, for a simple "Hello world!" program in C, it...
View ArticleHow to install MinGW 64 from Sourceforge?
All I want to do is install the 64 bit version of MinGW along with compilers and other development utilities. Google sent me to Sourceforge - https://sourceforge.net/projects/mingw-w64/. I clicked the...
View ArticleWhy std::size() is not a member of std in gcc 8.2.0
I'm trying to teach myself some C++17.Why is the compiler throwing an error for the below code snippet?#include <iostream> #include <vector>#include <iterator>int main() {...
View ArticleOpenMP GPU offloading math library?
I am trying to offload code the GPU using OpenMP 4+ directives. I am using ubuntu 16.04 with GCC 7.2 and for general cases it is working fine. My problem comes when I am trying to offload a code that...
View Article