Why didn't gcc implement _s functions?
_s functions, such as scanf_s, printf_s seems to be optional standard. MSVC has implemented these functions, but gcc hasn't.Is there specific reason for not implementing secure functions? Is scanf of...
View ArticleRestriction on child pointer of a restricted pointer?
The article mentions:Restricted pointers can be copied from one to another to create a hierarchy of pointers. However there is one limitation defined in the C99 standard. The child pointer must not be...
View ArticleStatic assert in C
What's the best way to achieve compile time static asserts in C (not C++), with particular emphasis on GCC?
View Articlex86_64 gcc debug-mode: Why is there an extra instruction in add vs subtract?
I wrote the following snippet.int Add(int x, int y) { return x+y; } int Subtract(int x, int y) { return x-y; } int main() { bool flag = false; int x=10,y=5,z; if (flag) { z = Add(x,y); } else { z =...
View Articletemplate Recurses infinitely on gcc (but fine on clang) [closed]
Example code:template <typename DestType> struct CInsertable { template <typename T> auto Requires(DestType Dest, T& Val) -> decltype( Dest << Val ); }; fails on...
View ArticleHow to build or get a original latest version of GCC for Windows?
I want a latest version of GCC for Windows. Now the latest version is 9.2 but for Windows via MinGW it is just 8.1... I have tried to build from source for Windows 10 include WSL, but have not found...
View ArticleWhat is C17 and what changes have been made to the language?
As I was checking news about GCC 8, I saw that they added support for the 2017 version of the C language (not C++17, really C17). But I can't find any information about it on Internet.Is it a new ISO...
View ArticleWhy doesn't likely and unlikely macros have any effect on ARM assembly code?
I took below example from https://kernelnewbies.org/FAQ/LikelyUnlikely#include <stdio.h> #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) int main(char...
View ArticleSEM_FAILED on GCC Red Hat 4.8.5-39 - Semaphores
This is simple shared memory program that I tried writing: #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/mman.h> #include <getopt.h> #include...
View ArticleSwitch statement doesn't run — but no compilation issues [duplicate]
This question already has an answer here:Why does scanf ask twice for input when there's a newline at the end of the format string? 6 answers#include <stdio.h> #include <conio.h> int...
View ArticleIs there a way to auto-generate MMX instructions (not SSE) with gcc
It appears gcc will happily auto-vectorize simple examples, and emit SSE instructions. Is there any way to emit MMX instructions only?For example if I try the following example on Godbolt:int...
View Articleld fails to find libc when compiling first pass of (cross?) gcc
I'm preparing a native toolchain for use in a custom build system. I took LFS 8.4 book as a base. The biggest deviation from the book is that I'm not using /tools symlink in system as I don't want to...
View ArticleHow to set up and compile a binary for format string attacks?
I wanted to practise format strings attack, so i wrote a small programformat.c:#include <stdio.h> char input[1024]; int main() { fgets(input, sizeof(input), stdin); printf(input); } I compiled it...
View ArticleWhat are the differences between attributes and pragmas in C++? [duplicate]
This question already has an answer here:what is the difference between __attribute__((__packed__)); and #pragma pack(1) 1 answerI am interested in the context of C++ code, using compilers such as...
View ArticleCompiler optimization causing strange behavior with bit-wise shifts [duplicate]
This question already has an answer here:Left shift an integer by 32 bits 2 answersDisclaimer, this is about shift overflows which I know gives undefined behavior; so this really shouldn't be a...
View Articleclang: error: : errorunsupported option '-fopenmp' on Mac OSX El Capitan...
I'm trying to build XGBoost package for Python following these instructions: Here is the complete solution to use OpenMP-enabled compilers to install XGBoost. Obtain gcc-5.x.x with openmp support by...
View ArticleDoes GCC have a built-in compile time assert?
Our existing compile-time assert implementation is based on negative array index, and it provides poor diagnostic output on GCC. C++0x's static_assert is a very nice feature, and the diagnostic output...
View ArticleExpected unqualified id before “.” token
I see the above question(and similar questions) are answered at various places here, here and here, but none of them explains what I am really after.I also saw a very good explanation of qualified /...
View ArticleWhat does the fpermissive flag do?
I'm just wondering what the -fpermissive flag does in the g++ compiler? I am getting:error: taking address of temporary [-fpermissive]which I can solve by giving the -fpermissive flag to the compiler....
View Articlefatal error: json-c/json.h: No such file or directory Cross compiling on...
I am trying to compile my code on my Ubuntu x64 laptop for the Raspberry Pi. I am able to compile and run the code on Ubuntu laptop without any issue. However when I try to compile it for Raspberry Pi...
View Article