Quantcast
Channel: Active questions tagged gcc - Stack Overflow
↧

Does GCC optimize array access with __int128 indexes incorrectly?

When compiling the following code using GCC 9.3.0 with O2 optimization enabled and running it on Ubuntu 20.04 LTS, x86_64 architecture, unexpected output occurs.#include <algorithm>#include...

View Article


Should I always use __builtin_extract_return_addr after __builtin_return_address

The gcc documentation:Additional post-processing of the returned value may be needed, see __builtin_extract_return_addr.The stored representation of the return address in memory may be different from...

View Article


Is it possible to compile Linux kernel with something other than gcc

I wonder if someone managed to compile the Linux kernel with some other compiler than gcc. Or if someone have ever tried? Question may seem to be silly or academic, but it arose when I thought about...

View Article

What causes the "undefined reference to ..." error when compiling with gcc

I encountered an error while attempting to compile a larger project. I didn't have any problems with this before when I was using the Code Blocks IDE. To diagnose the issue I attempted to recreate the...

View Article

Cross compile x64_86 (-mx32) build on Linux 686 OS missing

I have an existing library that is compiled using gcc (Debian 10.2.1-6) 10.2.1 20210110 for 32bit code on Linux devuan-chimaera 5.10.0-31-686 #1 SMP Debian 5.10.221-1 (2024-07-14) i686 GNU/Linux.I want...

View Article


What is long long under __X86_64__? [duplicate]

I see this in int-ll64.h when building for -m64__extension__ typedef unsigned long long __u64;does this mean it's 128 bits instead of 64.The compiler certain complains that the definition of:typedef...

View Article

A class is defined using __FILE__ in two different files; which definition is...

main.cpp:#include <iostream>struct Cls { static void some_method() { std::cout << __FILE__ << ": " << __LINE__ << std::endl; }};extern void call_some_method();void...

View Article

Does gcc treat relaxed atomic operation as a Compiler-fence?

I have following code with GCC8.3 ,x86-64 linux:// file: inc.ccint inc_value(int* x) { (*x)++; //std::atomic<int> ww; //ww.load(std::memory_order_relaxed); (*x)++; return *x;}This generates...

View Article


How can I prevent GCC from optimizing out a busy wait loop?

I want to write a C code firmware for Atmel AVR microcontrollers. I will compile it using GCC. Also, I want to enable compiler optimizations (-Os or -O2), as I see no reason to not enable them, and...

View Article


How to fix "fatal error:...

I want to use ordered_set in C++, for that I copied the header files from here.The header files are:include <ext/pb_ds/assoc_container.hpp>include <ext/pb_ds/tree_policy.hpp>When I compile...

View Article

GMP 4.2 linker failure - multiple definitions in assert.o

I need to compile an old version of GCC and it requires also old version of several libs.One of them is gmp-4.2.When trying to build gmp 4.2, ./configure is performed without errors, but make is...

View Article

"program_invocation_name" not compiled under MacOS

Trying to print the program name using program_invocation_name#include <stdio.h>#define _GNU_SOURCE#include <errno.h>#include <stdlib.h>int main(int argc, char *argv[]){ extern char...

View Article

GCC warning: 'memcpy' specified bound 18446744073709551614 exceeds maximum...

Compiling Lua (version 5.4.7) with the GCC 15.2.0 compiler as C++, I get a strange warning message...\lauxlib.c|586|warning: 'memcpy' specified bound 18446744073709551614 exceeds maximum object size...

View Article


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...

View Article

g++ 5.4.0 - unable to use C++14 standard

I installed gcc 5.4.0 recently, on Windows using Cygwin, because I wanted to test the C++14 standard features of g++. When I tried to compile, I get the following error: $ g++-5.4.0 -std=c++14...

View Article


gcc-8 -Wstringop-truncation what is the good practice?

GCC 8 added a -Wstringop-truncation warning. From https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82944 :The -Wstringop-truncation warning added in GCC 8.0 via r254630 for bug 81117 is specifically...

View Article

Benchmark C++ vs Java, Unrealistic results

I did a simple test, I know C++ is often faster but weirdly the results of this test is unrealistic to my eyes. So, I think there is something about C++ that I don't know.C++ code is:#include...

View Article


Is there any way to get 64-bit time_t in 32-bit programs in Linux?

On Windows I can call:_time32(__time32_t); // to get 32-bit time_t_time64(__time64_t); // to get 64-bit time_t(both in 32 and 64-bit programs)Is there any way do this in Linux (compiling with GCC)?

View Article

GCC: Building cross-compiler for ARM - pthread.h not found

Using a Ubuntu 12.04 host, I carefully followed this SO answer here (Recipe for Compiling Binutils and GCC Together) to build GCC and binutils in one tree with all of their dependencies.Here is the...

View Article

Linux Makefile project debugging best practices and tools

I'm coming from Windows background and are diving a little into Linux programming. I'm interested, what are the best practices in debugging a classical Makefile project (breakpoints, stepping, call...

View Article

Where does gcc look for C and C++ header files?

On a Unix system, where does gcc look for header files?I spent a little time this morning looking for some system header files, so I thought this would be good information to have here.

View Article


Static assert in C

How can compile-time static asserts be implemented in C (not C++), with particular emphasis on GCC?

View Article


MSP430 GDB hangs while processing a for loop-based delay

I'm using the MSP430-GCC-OPENSOURCE toolchain, based on gcc-9.3.1.11, developed by TI in collaboration with Mitto Systems. When I debug the following code in Eclipse Embedded using msp430-elf-gdb, the...

View Article

Ignore all warnings from system headers, even for inlined functions

Previously you could mark the respective include directories as system directories (by using -isystem instead of -I on the command line) and GCC would not emit any warnings from those headers.However,...

View Article

Is there a way to make a header file, like stdio.h and not include it in the...

I'm trying to make a library and I've found that I need to make a header file, which I did and I have a C file too, which contains the functions.wprintf.h:#ifdef WPRINTF#include <wchar.h>void...

View Article


What are the differences between the -l and -L linking options?

I'm new to the world of building. I've always let my IDE take care of it for me, but now I'm working with autotools and the command line.Could someone explain the difference between gcc's -l LIBNAME -...

View Article

Is there a 128 bit integer in gcc?

I want a 128 bit integer because I want to store results of multiplication of two 64 bit numbers. Is there any such thing in gcc 4.4 and above?

View Article

An internal compiler error (ICE) is encountered with GCC, and compiling with...

This C++ static reflection code can automatically obtain the number and names of member variables in an aggregate class, with its core process divided into three steps:1.At compile time, calculate the...

View Article

Unable to use std::format for integer formatting - gcc 15.1.0

I am using gcc 15.1.0 docker image. I was running my C++ code but I encountered a very weird issue that I am unable to resolve. Attaching the minimal reproducer (I can't remove the import inside...

View Article



When locating C program header/s (.h) program is using. Looking for a certain...

Quite often one wants to know which header/s (path to programheader.h) your C program is depending on. You can list all, with the command mentioned below, but what if looking for a certain one from the...

View Article


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>