Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [gcc]

GCC is the GNU Compiler Collection. It's the de facto standard compiler for C, C++, Go, Fortran, and Ada on Linux and supports many other languages and platforms as well.

358 votes
15 answers
576k views

Removing trailing newline character from fgets() input

I am trying to get some data from the user and send it to another function in gcc. The code is something like this. printf("Enter your Name: "); if (!(fgets(Name, sizeof Name, stdin) != NULL)) { ...
sfactor's user avatar
  • 12.9k
116 votes
3 answers
34k views

How to remove "noise" from GCC/clang assembly output?

I want to inspect the assembly output of applying boost::variant in my code in order to see which intermediate calls are optimized away. When I compile the following example (with GCC 5.3 using g++ -...
m.s.'s user avatar
  • 16.2k
597 votes
11 answers
260k 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?
Landon's user avatar
  • 15.5k
50 votes
1 answer
20k views

32-bit absolute addresses no longer allowed in x86-64 Linux?

64 bit Linux uses the small memory model by default, which puts all code and static data below the 2GB address limit. This makes sure that you can use 32-bit absolute addresses. Older versions of gcc ...
A Fog's user avatar
  • 4,540
245 votes
12 answers
350k views

Multiple glibc libraries on a single host

My linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won't work on this version and requires glibc-2.3.3. Is it possible to have multiple glibcs installed on the same ...
dogbane's user avatar
  • 272k
107 votes
3 answers
40k views

Is gcc 4.8 or earlier buggy about regular expressions?

I am trying to use std::regex in a C++11 piece of code, but it appears that the support is a bit buggy. An example: #include <regex> #include <iostream> int main (int argc, const char * ...
tunnuz's user avatar
  • 23.7k
276 votes
5 answers
39k views

Why does GCC use multiplication by a strange number in implementing integer division?

I've been reading about div and mul assembly operations, and I decided to see them in action by writing a simple program in C: File division.c #include <stdlib.h> #include <stdio.h> int ...
qiubit's user avatar
  • 4,806
189 votes
11 answers
93k views

Why does flowing off the end of a non-void function without returning a value not produce a compiler error?

Ever since I realized many years ago, that this doesn't produce an error by default (in GCC at least), I've always wondered why? I understand that you can issue compiler flags to produce a warning, ...
Catskul's user avatar
  • 18.7k
1884 votes
37 answers
1.8m 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 ...
Mohanad Y.'s user avatar
  • 19.2k
26 votes
1 answer
14k views

How to load address of function or label into register

I am trying to load the address of 'main' into a register (R10) in the GNU Assembler. I am unable to. Here I what I have and the error message I receive. main: lea main, %r10 I also tried the ...
user avatar
55 votes
16 answers
75k views

Why is scanf() causing infinite loop in this code?

I've a small C-program which just reads numbers from stdin, one at each loop cycle. If the user inputs some NaN, an error should be printed to the console and the input prompt should return again. On ...
user avatar
36 votes
3 answers
9k views

Why doesn't GCC use partial registers?

Disassembling write(1,"hi",3) on linux, built with gcc -s -nostdlib -nostartfiles -O3 results in: ba03000000 mov edx, 3 ; thanks for the correction jester! bf01000000 mov edi, 1 31c0 ...
Ábrahám Endre's user avatar
557 votes
21 answers
898k 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 ...
RyanG's user avatar
  • 7,033
18 votes
1 answer
4k views

How can I indicate that the memory *pointed* to by an inline ASM argument may be used?

Consider the following small function: void foo(int* iptr) { iptr[10] = 1; __asm__ volatile ("nop"::"r"(iptr):); iptr[10] = 2; } Using gcc, this compiles to: foo: nop ...
BeeOnRope's user avatar
  • 63.7k
697 votes
31 answers
510k 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 ...
KPexEA's user avatar
  • 16.7k

15 30 50 per page
1
2 3 4 5
464