gcc
Status of __STDC_IEC_559__ with modern C compilers
I believe __STDC_IEC_559__ relies on some library features and can’t be defined solely by the compiler. See this post for some information. This is not uncommon for C — the compiler and the C library must sometimes cooperate in order to implement the entire standard. What you’re asking depends on the compiler. I think you … Read more
Integer overflow in C: standards and compilers
Take a look at -ftrapv and -fwrapv: -ftrapv This option generates traps for signed overflow on addition, subtraction, multiplication operations. -fwrapv This option instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. This flag enables some optimizations and disables other. This option is enabled by … Read more
Actual default linker script and settings gcc uses
Well, I know that this is an old question, but I also found it frustrating that there is no precise info about options that are used during the linking process. This answer shows my journey to find them. First of all, I was looking into official docs https://gcc.gnu.org/onlinedocs/ – I searched the GCC Manual and … Read more
how to install gcc-12 on ubuntu
gcc-12 is not available in ubuntu 20.04, so we need to compile it from source code, here are the steps which I borrowed from this video: Step 1: clone gcc source code and checkout gcc-12 branch $ git clone https://gcc.gnu.org/git/gcc.git gcc-source $ cd gcc-source/ $ git branch -a $ git checkout remotes/origin/releases/gcc-12 Step 2: make … Read more
correct usage of rpath (relative vs absolute)
In the case of rpath, it makes no sense to use a relative path, since a relative path will be relative to the current working directory, NOT relative to the directory where the binary/library was found. So it simply won’t work for executables found in $PATH or libraries in pretty much any case. Instead, you … Read more
Golang: How to cross compile on Linux for Windows
To build from Linux to Windows, you need to set the environment variables GOOS to Windows and GOARCH to amd64. On Bash or ZSH: % GOOS=windows GOARCH=amd64 go build For more details see: https://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5 A description of possible values for GOOS and GOARCH is available here: https://golang.org/doc/install/source#environment If your package requires CGO then you need … Read more
Why isn’t the keyword false an integer constant expression in gcc C23?
In addition to the paragraphs quoted in the question, there is paragraph 6.4.4.5/3: The keywords false and true are constants of type bool with a value of 0 for false and 1 for true. and 6.6/7: An identifier that is: […] — a predefined constant; […] is a named constant That makes false a named … Read more
gcc -O0 still optimizes out “unused” code that should raise an FP exception. Is there a compile flag to change that?
Why does gcc not emit the specified instruction? A compiler produces code that must have the observable behavior specified by the Standard. Anything that is not observable can be changed (and optimized) at will, as it does not change the behavior of the program (as specified). How can you beat it into submission? The trick … Read more
Typing “gcc –version” outputs clang version instead on mac
You seem to not actually have gcc on your path. As of recent versions of Xcode, it installs a “gcc” that is instead a link to Clang.