How did moving calculations from run-time to compile-time make my code slower?
I'm writing a function to calculate the fast Fourier transform using the Stockham FFT algorithm and discovered that all of the "twiddle factors" for the calculation can be pre-calculated at compile...
View ArticleInline assembly multiplication "undefined reference" on inputs
Trying to multiply 400 by 2 with inline assembly, using the fact imul implicity multiplies by eax. However, i'm getting "undefined reference" compile errors to $1 and $2 int c; int a = 400; int b = 2;...
View Articleperror() give seg. fault
After an error occurs, I call perror(), naturally. But I'm getting a segmentation fault when I do this or printf("error: %s\n", strerror(errno)); I have no idea what is happing. int fd; if((fd =...
View ArticleNon-Temporal Load (MOVNTDQA) operand type, alignment, and asm syntax
I'm trying to execute a non-temporal load using the VMOVNTDQA instruction on a data array that has been allocated using posix_memalign() (assume this is write-combining by changing the library), with...
View ArticleAttempting to tamper proof my executable with some hashing but coming across...
In an attempt to tamper proof my executable with some hashing I've come across some unexpected and unknown compiler behaviour.I have this idea of calculating a simple hash value of my program by simply...
View ArticleHow to integrate WinBuild and VS Code? [closed]
I am trying to compile C++ using VS code and WinBuild (yypkg), is this possible?I have downloaded MinGW, GCC and G++, and the include folder checks out.Reference or step my step instruction would be...
View Articleuse macro to test function return value in C
I want to have a macro which does something like:#define TEST(_ptr) ({ if ((_ptr) == NULL) ERROR; (_ptr); })which check _ptr and calls ERROR macro or return its value.However, if I use something like...
View ArticleC Segmentation Fault While using scanf for 2D array
As suggested by a book of "Gottfried", I tried to input an array and display the contents of array in matrix form : #include<stdio.h> #define row 2 #define col 3 int main(){ int (*a)[col]; int...
View ArticleUsing lodsb to move a byte into another address using inline c [duplicate]
I'm learning inline assembly in c and I'm trying to load a byte into another variable so I can eventually get into working with strings.My current code took a pretty simple approach with my comments...
View Article_Generic: suppress "error: undeclared (first use in this function)"
code:int foo_i(int i) { return i; } #define foo(type) _Generic((type), int: foo_i, float: foo_f) int main(void) { int var1 = 42; int var2 = foo(var1); return 0; } GCC error:error: ‘foo_f’ undeclared...
View ArticleGCC ARM Performance drop
I stumbled upon very strange issue with GCC. The issue is 25% drop in performance. Here is the story.I have a pice of software which is fp32 compute intensive (neural networks compiled with TVM). I...
View ArticleGCC Werror flag leads to "no option" error
I found the Wabsolute-value warning which I want to use as an error. However I get cc1.exe:-1: error: error: -Werror=absolute-value: no option -Wabsolute-value When I try the warning itself, I get...
View ArticleError compiling with GCC/Clang on Mavericks
Apparently Apple removed gcc with the latest OS and now gcc maps to clang. Anyhow, I installed the latest Command Line Tools (Oct 22nd version), but still get the following error messages when trying...
View ArticleCompile C for Windows with MinGW
I installed the latest version of MinGW and trying to compile the project:\MinGW\bin\gcc.exe -O3 -flto -Wall -msse src/*.c -o noname -lm -lpthread But nothing happens. No errors, no exe files,...
View ArticleRelocation R_X86_64_32S against `.bss' can not be used when making a PIE...
I'm trying to compile AccNEAT project with CUDA support. It's working fine when I compile it without CUDA support. However, when I compile with CUDA support, I get linker errors. To compile the...
View ArticleC code Optimization by compiler for atmel studio
I am using Atmel Studio 7 and in that, optimization level is -O1. Can I check what portion of code is being optimized by the compiler itself? If I am disabling the optimization, my binary file size is...
View ArticleSymbol reference resolution for dynamically loaded libraries on linux
I was trying to understand how symbols are resolved in case of dynamically loaded libraries. I observed that the symbols of the libraries are resolved using the libs linked as the dynamic dependencies...
View ArticleIs there a C snippet that computes overflow-safe addition efficiently without...
Here is a C function that adds an int to another, failing if overflow would happen:int safe_add(int *value, int delta) { if (*value >= 0) { if (delta > INT_MAX - *value) { return -1; } } else {...
View ArticleOpenMP invalid controlling predicate - persistent
I keep getting this error for >6 hours now when trying to compile C-code with -fopenmp flag using gcc.error: invalid controlling predicate for ( int i = 0; i < N; i++ )I browsed stackoverflow and...
View Articleg++ user-defined global new and delete operators on dynamically linked libraries
On g++, code from dynamically linked libraries uses operator delete from the main program. With the -Wl,-Bsymbolic option, the dynamically linked library used its own operator new but uses the main...
View Article