Is there any sanitizer setting in GCC or Clang that can detect the use of...
These C and C++ programs use uninitialized memory:C:#include <stdio.h>#include <stdlib.h>int main(void) { double* p = malloc(100*sizeof(double)); printf("%f\n", p[22]);...
View Articleld: building for macOS-x86_64 but attempting to link with file built for...
I have this strange issue where creating / using a static library works in my Ubuntu VM but not on macOS:ld: warning: ignoring file ./dist/libXXXX.a, building for macOS-x86_64 but attempting to link...
View ArticleMixing GCC/LLVM C2y preprocessor vector extension with arrays and...
Are there any alternatives for __builtin_vectorelements in GCC?Replacing vec_countof for GCC with another solution might help.array.h - C preprocessor arr/vec(T,N) data types#pragma once#include...
View ArticleBuilding 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 ArticleHow to compile the Linux kernel with -O0 for more detailed debug?
I'm hacking the Linux kernel v5.15 and try to debug it with gdb line by line. I've opened the dwarf debug info through make menuconfig. However, it seems that some line will still be skipped. I find...
View ArticleUnable to disable -pie with -no-pie. Both -pie and -no-pie are on compile line
I run a command like the following on my x86_64 host to build ARM binairies.make V=1 -C ./$TFA -j4 CROSS_COMPILE=$CC64 \ CFLAGS=-fno-pie LDFLAGS=-no-pie ARCH=aarch64 \ PLAT=k3 SPD=opteed K3_USART=0x6 \...
View ArticleIs there a direct way to get clear details on gcc acceptable option values...
The gcc (or g++) compiler has a -std option to specify the language standard to use for compiling C or C++. At the top level one can see that this option exists.gcc --help -std=<standard> Assume...
View ArticleMultiple arguments in the __section__ attribute
Could someone clarify for me the following statement I met in the code:static initcall_t initcall_comm_main0 attribute((used)) attribute((__section__(".application_initcall" "0" ".init"))) =...
View ArticleHardware interrupts not working in protected mode
I am working on a 32-bit protected mode operating system and I just added interrupts.I tested software interrupts and they do get fired from the interrupt keyword in assembly but hardware interrupts...
View Articleg++ error: no matching function for call to ‘fpclassify(float&)’
I use GCC 5.4.0 and Boost 1.67.0 on a Fedora 26 system (this is not the system's default compiler). If I compile the following a.cpp:#include <boost/any.hpp>with the command-line:g++ a.cpp -c -o...
View ArticleDifferent kinds of UB are processed differently by GCC
Consider these two functions:int foo(int a) { if (a) return 42; else return 17/a;}int bar(int* a) { if (a) return 42; else return *a;}Both have UB in the else branch. gcc seems to know that, but it...
View Articlegetting ld to ignore undefined references when making a DLL
I'm trying to get gcc's ld to ignore unresolved references when putting together a shared library from a bunch of object files compiled with -fpic flag.I tried a bunch of options so far such as...
View ArticleRust installation on Windows
I was trying to get Rust to work on my Windows box. I followed the instructions, however when I tried hello world program, it spits the below. It looks like it has not been able to link up to gcc.. and...
View ArticleC/C++ VS Code extension throwing build error: "The task provider for "C/C++"...
When I try to build a C task in VS Code it shows the following message: The Output just shows this: The task provider for "C/C++" tasks unexpectedly provided a task of type "shell".I can still manually...
View ArticleCompiling C/GTK within Eclipse
I'm fiddling around with the C/C++ version of Eclipse to build a simple GTK app. However, I can't seem to be able to compile a GTK sample from within Eclipse. I can compile a simple Hello World style...
View ArticleActivate a warning for int - float operation in gcc
Is there a way to activate in gcc a warning for all the times that there is a int - float operation?I have an old code with many arithmetic operation and I noticed that there are many situation like...
View ArticleHybrid relocatable/fixed arm gcc link output
I'm writing bootloaded firmware built by the Cortex M3 gcc cross-compiler. I want to express the following via a custom linker script or g++/ld switches as necessary.All machine code being emitted to...
View Article"Assume" clause in gcc
Does gcc (latest versions: 4.8, 4.9) have an "assume" clause similar to __assume() built-in supported by icc?E.g., __assume( n % 8 == 0 );
View Articlehow to create binary and .so using libtool
I have a set of cpp files that I want to compile directly into a binary and also to compile into a shared library.I have bin_PROGRAMS=mybinlib_LTLIBRARIES=libmylib.laCOMMON_SOURCES=f1.cpp f2.cpp...
View Articlestd::remove_if GCC implementation isn't efficient?
From another question here there seems to be evidence, that GCC's implementation of std::remove_if doesn't provide equally efficiency compared to the following implementation:'raw homebrew'...
View ArticleVSCode Debugging in internal console not working
I am using VS Code on Windows for my C/C++ assignments at University. I always wanted to debug my code in the integrated VS Code console because for me it is annoying to always have the second window...
View ArticleGCC vs MS C++ Compiler [closed]
I often read that the GCC compiler is much better than the Microsoft compiler on various forums and comment thread. This is always because "Micro$oft is evil" and that GCC is open-source. Are there any...
View ArticleCMake Detecting C compiler ABI info - failed
Coding the first example of the cmake tutorial it fails for C/C++ with ABI failed and as a result code to generate a target is not generated:gmake[2]: *** No rule to make target...
View Articlestd::vector and std::string reallocation strategy
What is the reallocation strategy used for std::string and std::vector in GCC's implementations?I'm interested in the specific strategy employed: When I append items to a vector (or chars to a string)...
View ArticleGCC: 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 ArticleFor what purpose does GCC create separate bitmasks applied to shifted items?
The following is a minimal reproducible example of code that I had to generate an 'array' (whose 1-byte elements are packed into the resulting uint_fast64_t) of 3D coordinates within octree branches...
View ArticleGCC:- unable to find libpthread_nonshared.a file while linking libraries to...
Hi I'm trying to compile a c project with gcc 10.2 in Ubuntu 20.04.But at the end it gives me error as below/usr/bin/ld: cannot find /usr/lib/x86_64-linux-gnu/libpthread_nonshared.acollect2: error: ld...
View ArticleLoop unrolling behaviour in GCC
This question is in part a follow-up question to GCC 5.1 Loop unrolling.According to the GCC documentation, and as stated in my answer to the above question, flags such as -funroll-loops turn on...
View ArticleHow to use __has_include correctly?
I am trying to dynamically include x11 libs if any present in system:#if __has_include(<X11/Xlib.h>) #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/X.h> #define...
View Articlegcc ON arm/android
I just got a EEE pad transformer. Like any hardware I own I'd like to have a C compiler on it. I know I can cross compile, but I'd like to do development ON the device itself. I've searched google and...
View Article