Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Browsing all 22199 articles
Browse latest View live

Why does loop alignment on 32 byte make code faster?

Look at this code:one.cpp:bool test(int a, int b, int c, int d);int main() { volatile int va = 1; volatile int vb = 2; volatile int vc = 3; volatile int vd = 4; int a = va; int b = vb; int c = vc; int...

View Article


std::destroy_at differences between major compilers?

Using compiler explorer with:#include <iostream>#include <memory>struct test{ test(int i) { std::cout << "test::test("<<i<<")\n"; } ~test() { std::cout <<...

View Article


How to do update-alternatives --config without having an interactive prompt?

So I'm trying to run these commands in the Github Actions environment:sudo update-alternatives --config x86_64-w64-mingw32-gccsudo update-alternatives --config x86_64-w64-mingw32-g++to change the...

View Article

gcc problem with std::optional and packed struct member

I need to use a packed struct for parsing incoming data. I also have an std::optional value that I want to assign the value of one of the struct members. However, it fails. I think I understand the...

View Article

Can different optimization levels lead to functionally different code?

I am curious about the liberties that a compiler has when optimizing. Let's limit this question to GCC and C/C++ (any version, any flavour of standard):Is it possible to write code which behaves...

View Article


Fatal error: iostream: No such file or directory in compiling C program using...

Why when I wan to compile the following multi thread merge sorting C program, I receive this error: ap@sharifvm:~/forTHE04a$ gcc -g -Wall -o mer mer.c -lpthreadmer.c:4:20: fatal error: iostream: No...

View Article

What is the difference between `-fpic` and `-fPIC` gcc parameters?

I've already read the gcc manpage, but I still can't understand the difference between -fpic and -fPIC. Can someone explain it, in a very simple and clear way?Related questions:What does -fPIC mean...

View Article

Bubble sort slower with -O3 than -O2 with GCC

I made a bubble sort implementation in C, and was testing its performance when I noticed that the -O3 flag made it run even slower than no flags at all! Meanwhile -O2 was making it run a lot faster as...

View Article


Building riscv-gnu-toolchain

I'm building the riscv-gnu-toolchain here: https://github.com/riscv-collab/riscv-gnu-toolchain like this: git clone https://github.com/riscv/riscv-gnu-toolchain.git cd riscv-gnu-toolchain git submodule...

View Article


MYSYS2 mingw64 gcc can't link Shared Libary

Hail,I'm attempting to link to a compiled shared library to main, and it tells me it cannot find the library - despite linking to a static library of the same name in a different folder having no...

View Article

GCC doesn't find functions in lib

I have a C file, which uses multiple lib files.I am trying to compile the file in the following way:gcc -o myprogram main.c list.lib filelib.libHowever, when trying to compile I get a bunch of...

View Article

-static option for gcc?

I'm wondering what the -static option on gcc does. I need this option when compiling a certain application, however when I do I get the following error:gcc -static -O3 -o prog prog.c/usr/bin/ld: cannot...

View Article

GCC cross compiler make vs make all-gcc, why does one give me an error but...

I built an i386-elf cross compiler by following this guide in the osdev wiki, however, before I found that guide, i was attempting to compile (and failing) by simply running make after configuring GCC....

View Article


Why does gcc implement fmin and fmax in three different ways?

I have a few routines here that all do the same thing: they clamp a float to the range (0-65535). What surprises me is that the compiler (gcc -O3) uses three, count 'em, three different ways to...

View Article

How does gcc linker find boost libraries?

I am getting started with the boost library for c++. Following the "getting started" steps here , I download and install boost on my Linux system using install method under 5.1 (using b2), the path to...

View Article


Why does C compiler needs declarations of a function in every source file...

If I define a function func1 in file1.c, and then use func1 in file2.c, why do I need to declare it in file2.c? Why can't the compiler just recognize that there is a definition in one of the files and...

View Article

gcc: Linking error in mixed language programming using C and Fortran

Based on this SO post I want to create software with gcc which uses mixed language source code, e.g. C and Fortran. While the linking of the generated object files works fine, the linker gives me the...

View Article


How to make GCC find dependent libraries when cross compiling?

I'm cross compiling for armv7l linux on x86_64 linux using the following setup:toolchain.cmake:set(CMAKE_SYSTEM_NAME Linux)set(CMAKE_SYSTEM_PROCESSOR arm)set(CMAKE_C_COMPILER...

View Article

c is not printing my valid variable value

I have new typedef struct && an init function for it.#include <stdlib.h>#include <stdio.h>typedef struct PERSON{ char * name; char * surname; int month; int day;} * Person;Person...

View Article

Building simple DLL with MinGW

I've read everything here and everything I can find on the net about doing this, but the information is out-of-date, contradictory, or inapplicable. I have a very simple library in C, which I compile...

View Article
Browsing all 22199 articles
Browse latest View live