Struct declared in C header file - gcc malloc error
I have declared a typedef struct on header files as follows:myheader.htypedef struct mystruct mystruct; myheader.ctypedef struct mystruct{ double *ptr1; double *ptr2; int *ptr3; mystruct *ptr4;...
View ArticleHow to convert string representation of an arbitrary length integer in a...
I was wondering how would you convert an arbitrary length integer integer in some base b represented by a string into a string representation in base 10.To give you an example, if I send the string...
View Articlewhen I include atomic.h, GCC says No such file, why?
I want to use atomic API, and I include . I don't know how to use it! Thank you!I have it in /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/atomic.h.I also add...
View ArticleWhat are the GCC default include directories?
When I compile a very simple source file with gcc I don't have to specify the path to standard include files such as stdio or stdlib.How does GCC know how to find these files?Does it have the...
View Articlegcc: xtensa LX106 (ESP8266) missing symbol names from ELF executable
I have a issue with gcc (5.2.0) for Xtensa LX106 CPU (ESP8266) that appears to omit some symbol names from executable (ELF) while they exists in *.map file and I am trying to understand why.This is...
View ArticleIn function __libc_init_array: undefined reference to _init
I'm trying to build a simple program (infinite loop) for the stm32 on the command line (Linux) and the commands used to compile and link are taken from a tutorial. I get stuck at the linking stage and...
View Articlegcc assembler - create only the minimal instructions necessary
I have created a very minimal application in assembly. It sets some registers to 0 and does a multiplication. Nothing fancy.However, the gcc adds a lot of stuff to the machine code I do not want.A...
View ArticleFast dot product using SSE/AVX intrinsics
I am looking for a fast way to calculate the dot product of vectors with 3 or 4 components. I tried several things, but most examples online use an array of floats while our data structure is...
View ArticleRun Plain C Project in Qt Creator
I created a plain c project in qt creator using File->New file or Project->Non Qt Projects->Plain C Projectmain.c#include <stdio.h> int main(void) { printf("Hello World!\n"); return 0; }...
View ArticleXcode gcc: dependency_info.dat No such file or directory
Hi anyone can help with dependency_info.dat No such file or directory? I'm using Xcode 7 with gcc 4.8-dependency_info...
View ArticleUnexpected runtime of loop
I am coding a side channel attack demo. I expected a simple character-by-character check with early return to take a linearly-proportional time to the first incorrect character. For example, if I have...
View ArticleWhy do GCC atomic builtins need an additional "generic" version?
According to https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html, there's:type __atomic_load_n (type *ptr, int memorder) and (the "generic"):void __atomic_load (type *ptr, type *ret, int...
View Articlegets() without apology
I use the gets() function a lot in my own programming. I know that:the input string may overflow the allocated spacein some environments, the above can be used to create an exploitthat fgets() can be...
View ArticleHow to stop GNU Fortran Compiler to show debug info during runtime?
The following lin is used to compile an executable from the Fortran source codegfortran -funderscoring -O3 -Wall -c -fmessage-length=0 -o "src/abc.o""../src/abc.f"When I run my program in command...
View ArticleGCC: static data member optimized out in the debug build
Consider the following simple code:template<typename T> struct Base { static constexpr int v = 0; }; struct Derived : Base<int> {}; int main() { Derived d; } I compile it with GCC (8.3.0,...
View ArticleHow to get the number of warnings/errors during the build?
Is this possible to easily get the number of warnings and errors during a build with gcc?My current solution (which is ugly) is: gcc foo.c 2>&1 | grep warning: | wc gcc foo.c 2>&1 | grep...
View ArticleWhat does -c option do in GCC [closed]
Does anyone know what does the -c flag do in gcc?For example, what's the difference betweengcc -c output0.c vs gcc output0.c I know the second one makes a .a file but I don't know what a .a file...
View Article.dbug_loc is missing from binary
I was inspecting ELF binary for the code mentioned below. I compiled it on gcc 7.4.0 on Ubuntu x86_64 system in Virtual Box as : gcc -g scratch1.c -o scratch1.out #include <stdio.h> void...
View ArticleHow to export kernel functions which written in assembly?
I am working with a PowerPC processor and have to use dcache functions in my kernel module, like: "clean_dcache_range()", implemented in $KERNEL_SOURCE/arch/powerpc/kernel/misc_32.S. this assembly file...
View Article"/usr/bin/ld: cannot find -lz"
I am trying to compile Android source code under Ubuntu 10.04. I get an error saying,/usr/bin/ld: cannot find -lzCan you please tell me how can I fix it? What does cannot find -lz mean? Here's the full...
View Article