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.

GCC is the GNU Compiler Collection, a collection of free software compilers. It is a key component of the GNU Toolchain.

GCC includes an optimizing C compiler that is the most commonly used C compiler on Linux. GCC also includes front ends for C++ (including full support for C++17), Objective-C, Fortran, Ada, and Go, as well as libraries for these languages (libstdc++, libgfortran, ...). It supports many architectures.

GCC sources are available via the Git repository. Major decisions about GCC are made by the steering committee, guided by the mission statement.

See also GCC online documentation and the home page, and release dates.

40905 questions
20
votes
7 answers

Layout of compiled objects

Is there a way—much like viewing the result of preprocessing with gcc -E—to see what my objects look like once compiled into object files? I am talking about GCC, but a solution including MSVC would be fine.
user257620
  • 223
  • 2
  • 5
20
votes
4 answers

GCC: accuracy of strict aliasing warnings

I'm trying to check some of my code for strict aliasing violations, but it looks like I've missed something while trying to understand the strict aliasing rule. Imagine the following code: #include int main( void ) { unsigned long…
Macmade
  • 52,708
  • 13
  • 106
  • 123
20
votes
3 answers

Multiple "could not be resolved" problems using Eclipse with minGW

I have recently installed (the latest builds of) 'Eclipse IDE for C/C++ Developers' and minGW (4.8.1) to help me to get back into C++ after a long time away. I have added -std=c++11 to Other flags at C/C++ Build/Settings/Tool Settings/GCC C++…
Jim
  • 423
  • 1
  • 4
  • 13
20
votes
1 answer

Why does tree vectorization make this sorting algorithm 2x slower?

The sorting algorithm of this question becomes twice faster(!) if -fprofile-arcs is enabled in gcc (4.7.2). The heavily simplified C code of that question (it turned out that I can initialize the array with all zeros, the weird performance behavior…
Ali
  • 56,466
  • 29
  • 168
  • 265
20
votes
2 answers

How to disable narrowing conversion warnings?

I use -Wall and updating to new gcc I have got a lot of warning: narrowing conversion. I want to disable them, but leave all other warnings untouched (ideally). I can find nothing about narrowing in…
klm123
  • 12,105
  • 14
  • 57
  • 95
20
votes
1 answer

What is GCC lto wrapper?

I am using buildroot to prepare images for embedded system. I want to export buildroots internal cross compiler so others can use same version, After command checking GCC version: arm-linux-gcc -vI see configured COLLECT_LTO_WRAPPER to static…
Mihalko
  • 563
  • 2
  • 5
  • 14
20
votes
2 answers

Compile all .c files in a directory using GCC compiler in CMD

Is there a way to compile all .c files in a given folder by using the command line with GCC compiler ? I've seen this page for Linux : http://www.commandlinefu.com/commands/view/3230/compile-all-c-files-in-a-directory but couldn't find any…
SagiLow
  • 5,721
  • 9
  • 60
  • 115
20
votes
2 answers

Multiple definition of first defined here gcc

I have these files consumer.cpp consumer.hpp defines.hpp main.cpp makefile producer.cpp producer.hpp here's the file defines.hpp #ifndef DEFINES_HPP #define DEFINES_HPP #include #include #include #include…
user1886376
20
votes
1 answer

Compiling a .C file: Undefined symbols for architecture x86_64

For some reason i get an error message after compiling a .c program. 11 warnings generated. Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture…
chuckfinley
  • 2,577
  • 10
  • 32
  • 42
20
votes
3 answers

GDB says "no symbol table," but nm shows file has debug symbols

I'm trying to debug a simple C project using GDB, but GDB can't seem to find the debug symbols for the program no matter how I compile it. When I load the program into GDB, it claims to have read the symbols successfully because it prints Reading…
Edward
  • 5,942
  • 4
  • 38
  • 55
20
votes
1 answer

static initialisation of a char array in a constant struct from C to C++

I have some existing code in C: extern const struct sockaddr_un addr = { .sun_family = AF_UNIX, .sun_path = "myreallylongpath" }; Where sun_path is a character array. This used to compile fine as C in an older version of GCC. I have now…
Joe
  • 7,378
  • 4
  • 37
  • 54
20
votes
2 answers

Linking C compiled static library to C++ Program

I tried to link a static library (compiled with gcc) to a c++ program and I got 'undefined reference'. I used gcc and g++ version 4.6.3 on a ubuntu 12.04 server machine. For example, here is the simple library file for factorial…
Prabu
  • 1,225
  • 4
  • 18
  • 26
20
votes
2 answers

execute binary machine code from C

following this instructions I have managed to produce only 528 bytes in size a.out (when gcc main.c gave me 8539 bytes big file initially). main.c was: int main(int argc, char** argv) { return 42; } but I have built a.out from this assembly…
4pie0
  • 29,204
  • 9
  • 82
  • 118
20
votes
4 answers

gcc failing to warn of uninitialized variable

The following code has a variable that may be uninitialized. It seems that gcc should be generating a warning but isn't: $ cat a.c int foo(int b) { int a; if (b) a = 1; return a; } $ gcc-4.7 -c -Wall -Wmaybe-uninitialized -o a.o ./a.c $…
clandau
  • 201
  • 1
  • 2
  • 3
20
votes
1 answer

Cross compilation: GCC ignores --sysroot

I'm trying to cross compile programs (currently avconv from libav) for a Nokia N9 phone using arm-linux-gnueabi-gcc from Linux Mint's 64-bit repository. The compiler's libc version is 2.15 and the phone has libc-2.10.1. They have an incompatibility…
trololo
  • 369
  • 1
  • 3
  • 4