Why does 64-bit GCC warn about converting a const int to long unsigned int...
I have a file test.cpp that looks like this:void f(const int n) { unsigned char *a=new unsigned char[n]; delete[] a; } int main() { f(4); return 0; } Compiling it in 64-bit GCC with the...
View ArticleError installing python-snappy: snappy-c.h: No such file or directory
I am using amazon ec2 ubuntu 11.04 server sudo pip install python-snappy also I tried to downloaded package and entered "sudo python setup.py install"I got the error: running build running build_ext...
View ArticleThe advantages of using 32bit registers/instructions in x86-64
Sometimes gcc uses 32bit register, when I would expect it to use a 64bit register. For example the following C code:unsigned long long div(unsigned long long a, unsigned long long b){ return a/b; } is...
View Articlec binary file greater than source file [duplicate]
This question already has an answer here:size of executable files? 1 answerI have a c source file with name simple.c (file size 68 bytes) and I compiled it using gcc. The output binary file size is...
View ArticleHow to force static library to include it dependencies?
I build my own static library with gcc and ar like this.g++ \ ... list of library sources ... \ ... a lot of -L -l -I -D options etc... \ -c \ && ar crf ./lib/libpackager.a *.o Then I use this...
View Articlegcc compile function in ifdef
I have this code#include <stdio.h> void test2() { printf("start test2\n"); printf("end test2\n"); } void main () { printf("abc\n"); #ifdef A test2(); #endif } compile it with gcc test.c -o test...
View ArticleUnderstanding ASAN summary
The example below is from an ASAN report caused by heap-use-after-free on address 0x6040000a06b0 How would I be able to tell that this was a heap use after free error solely from looking at this...
View ArticleAlign C function to "odd" address
I know from C Function alignment in GCC that i can align functions using __attribute__((optimize("align-functions=32"))) Now, what if I want a function to start at an "odd" address, as in, I want it to...
View ArticleWhat is the equivalent of Keil _at_ in gcc
Does gcc have any keyword exactly equivalent to _at_ in Keil?struct Location { uint_32 x; uint_32 y; uint_32 z; char protocol[10]; }; struct link idata list _at_ 0x40; /* list at idata 0x40 */ Note: I...
View ArticleGCC C++ pow accuracy
So i was in a computing contest and i noticed a weird bug. pow(26,2) would always return 675, and sometimes 674? even though correct answer is 676. These sort of errors also occur with pow(26,3),...
View Articleconda build R package fails due to C compiler
I'm trying to install an R package called rcdd using conda build and there is a problem with the C compiler. Note that this problem looks very similar to Conda build R package fails at C compiler issue...
View ArticleIf GCC accepts C11 atomic_int casts and clang rejects them, which is correct?
Suppose I have the following C11 program:#include <stdatomic.h> int main() { int x = 0; // same behaviour if `atomic_int x`, surprisingly atomic_int y = (atomic_int) x; } If I compile this with...
View ArticleHow to detect compiler warnings in gitlab CI
In the steps of setting up CI builds on your gitlab server, I can't seem to find information on how to set up the detection of compiler warnings. Example build output:[100%] Building CXX object...
View Articleerror: command 'gcc' failed with exit status when installing psycopg2
i need to install psycopg2 for openerp installation process, but i always found that error. i've already used pip and easy_install, my gcc is the latest version. Really need your help to solve my...
View ArticleWhy does this C++ project fail to build even when appropriate .lib is linked in?
I am attempting to build sample code from Actian Btrieve (https://docs.actian.com/psql/btrieve2v13/html/btest_8cpp-example.html)It wouldn't build so I've simplified the code down to the following, just...
View ArticleGCC will compile but clang wont
So in my finals there was an exercise asking what will the program print.This is the code:#include <stdio.h> int main (){ int x=5, y=4; if (x>y); printf("A"); if(x=4) printf("%d",x+y); return...
View ArticleGCC Linking "undefined reference" with third part Shared Object (.so) file
Banging my head against a wall with making a quick proof of concept app which links to a third party .so file.I've produces a simple C file which calls a simple function in the .so file, it includes...
View ArticleTurning a statically linked library into a dynamic one
I know this question has been asked a few times, but none of the solutions have worked for me. I have a statically linked library that I would like to use with a JNI layer with versions pre Java 8....
View Articlegcc compiler ignores uninitialized variable warning for debug build
gcc compiler ignores uninitialized variable warning for debug build. This looks very weird for me, can some one help me to understand this ?## Program #include <stdio.h> #include <stdarg.h>...
View ArticleUsing Make and GCC from Docker to compile local source tree
So I am experimenting with Docker and I am contemplating a possibility of compiling a source tree on my local machine, using gcc& make and some more dependent libraries from a Docker container...
View Article