42,278 questions
2325
votes
12
answers
239k
views
Why doesn't GCC optimize a*a*a*a*a*a to (a*a*a)*(a*a*a)?
I am doing some numerical optimization on a scientific application. One thing I noticed is that GCC will optimize the call pow(a,2) by compiling it into a*a, but the call pow(a,6) is not optimized and ...
1939
votes
37
answers
2.0m
views
fatal error: Python.h: No such file or directory
I am trying to build a shared library using a C extension file but first I have to generate the output file using the command below:
gcc -Wall utilsmodule.c -o Utilc
After executing the command, I ...
1639
votes
24
answers
711k
views
Compiling an application for use in highly radioactive environments [closed]
We are compiling an embedded C++ application that is deployed in a shielded device in an environment bombarded with ionizing radiation. We are using GCC and cross-compiling for ARM. When deployed, our ...
1212
votes
11
answers
706k
views
What is the difference between g++ and gcc?
What is the difference between g++ and gcc? Which one of them should be used for general c++ development?
1112
votes
5
answers
138k
views
Why does the C preprocessor interpret the word "linux" as the constant "1"?
Why does the C preprocessor in GCC interpret the word linux (small letters) as the constant 1?
test.c:
#include <stdio.h>
int main(void)
{
int linux = 5;
return 0;
}
Result of $ ...
805
votes
2
answers
101k
views
Why is my program slow when looping over exactly 8192 elements?
Here is the extract from the program in question. The matrix img[][] has the size SIZE×SIZE, and is initialized at:
img[j][i] = 2 * j + i
Then, you make a matrix res[][], and each field in here is ...
705
votes
31
answers
533k
views
How to automatically generate a stacktrace when my program crashes
I am working on Linux with the GCC compiler. When my C++ program crashes I would like it to automatically generate a stacktrace.
My program is being run by many different users and it also runs on ...
637
votes
11
answers
633k
views
How do I list the symbols in a .so file
How do I list the symbols being exported from a .so file? If possible, I'd also like to know their source (e.g. if they are pulled in from a static library).
I'm using gcc 4.0.2, if that makes a ...
615
votes
11
answers
277k
views
Why does the order in which libraries are linked sometimes cause errors in GCC?
Why does the order in which libraries are linked sometimes cause errors in GCC?
605
votes
14
answers
2.9m
views
Convert char to int in C and C++
How do I convert a char to an int in C and C++?
603
votes
6
answers
856k
views
Debug vs Release in CMake [closed]
In a GCC compiled project,
How do I run CMake for each build configuration type (debug/release)?
How do I specify debug and release C/C++ flags using CMake?
How do I express that the main executable ...
603
votes
5
answers
426k
views
GCC -fPIC option
I have read about GCC's Options for Code Generation Conventions, but could not understand what "Generate position-independent code (PIC)" does. Please give an example to explain me what does it mean.
586
votes
21
answers
952k
views
Undefined reference to vtable
When building my C++ program, I'm getting the error message
undefined reference to 'vtable...
What is the cause of this problem? How do I fix it?
It so happens that I'm getting the error for the ...
574
votes
7
answers
156k
views
What exactly is LLVM?
I keep hearing about LLVM all the time. It's in Perl, then it's in Haskell, then someone uses it in some other language? What is it?
What exactly distinguishes it from GCC (perspectives = safety etc.)...
546
votes
17
answers
569k
views
How do you get assembler output from C/C++ source in GCC?
How does one do this?
If I want to analyze how something is getting compiled, how would I get the emitted assembly code?