Why two identical pointers do not compare equal with -O1? [duplicate]
#include <stdio.h> int main(void) { int a, b; int *p = &a; #ifdef __clang__ int *q = &b + 1; #elif __GNUC__ int *q = &b - 1; #endif printf("%p %p %d\n", (void *)p, (void *)q, p == q);...
View ArticleC++ resolve upper scope type at callsite [duplicate]
does anybody know why the following code snippet does not compile?struct A { struct Options { int a; int b; }; A(const Options& opt) : opt_(opt) {} Options opt_; }; template <typename T> T...
View Articlewhy will Mingw-w64 gcc compiler can not support %zd and %a format literally
i am using 8.1.0 gcc compiler when i tryprintf("%zd",sizeof(int)); printf("%a",float1); //float1=64.25f the compiler warns me:In function 'main': hellowo.c:6:12: warning: unknown conversion type...
View ArticleHow to align C structure to 4-byte boundary?
I have the following structure:typedef struct LOG_EVENT { time_t time; uint32_t count; int32_t error_type; uint16_t gm_state; uint8_t gm_mode; uint8_t mc_state; } LOG_EVENT; On 32-bit system , the...
View Articlewhy will Mingw-w64 gcc compiler generate wrong warning about the format of...
i am using gcc compiler and the command line is{gcc 'hellowo.c' -o 'hellowo.exe' -Wall -g -O2 -static-libgcc -std=c11 -fexec-charset=GBK} and the edtion infomation isgcc version 8.1.0...
View ArticleWhy -Wparentheses doesn't give warning for if (int x = someFunc())?
While compiling with -Wparentheses this will give a warning and it is understandableif (myVar= myFunct(param1)) { // do some stuff } but when we declare variable inside if block, compiler doesn't give...
View ArticleAre gcc's dynamically-sized arrays effectively identical to standard arrays...
In standard C and C++ the address of an array is the array itself, and sizeof returns the size of the array, not the pointer. However, does gcc's extension of dynamically-sized arrays offer the same...
View ArticleUnderstanding linked list code and how to fix it from moving the head?
I'm trying to figure out how to use linked lists and i'm sort of understanding, however i've ran into an error. I used a youtube tutorial which was good, however he did not explain this code and I...
View ArticleStatic linking of Fortran program with some C routines
I have a Fortran program with two small C routines for I/O. I use GCC to compile and link this on Windows, Linux and MacOS (well, on Catalina I need to use Mac's own C compiler) and it works.Now I...
View ArticleCan static linking eliminate dependancy issues
I need to compile a small code that will connect to (Open)LDAP Server and extract some info. Is there a chance for me to compile that code so that there are no needs for dependencies when i move that...
View ArticleDifference in digits10 between GCC and MSVC
I have the following code:#include <iostream> #include <limits> int main() { std::cout << std::numeric_limits<unsigned long long>::digits10 << std::endl; return 0; } GCC...
View ArticleHow to compile strace for ARM Linux?
I saw this project https://github.com/strace/strace. (is that the best project for strace?) And I have gcc cross compiler for Arm Linux.How can I compile it for Arm Linux? I look here...
View Articlesimple c++ "hello world" wont run with this error (.text+0x20): undefined...
hello i just want to compile this simple c++ code with vscode #include <iostream> using namespace std; int main(){ cout<<"hi"; return 0; } and i try to compile it with this command g++...
View ArticleWhat's the status of C++17 support in GCC?
Clang has a nice page describing the project status w.r.t. C++1z/C++17 feature support (and C++11 and C++14, it's the same page).g++ has a page regarding C++14 features, but I couldn't find anything...
View ArticleCompile Objective-C under Ubuntu
I found the following project: https://github.com/prasmussen/chrome-cliI would like to make this available for Linux as well. Unfortunately, I don't know much about Objective-C. Since the project was...
View ArticleIn Debian Error: "command 'gcc' failed with exit status 1" (pip install)
Hello. My have a goal, install pocketsphinx in python3 (3.7.5) or python3.8 (3.8.1). When I try install (in python3) module pocketsphinx, I can see more problem. The last, what I can't solve, this is...
View ArticleHow to specify -march=native using pragmas (or otherwise) in gcc
I would like to specify the compiler options for my C code that will be compiled in gcc. I need to do this from within the code because of the way the code will be deployed. This is the code currently...
View ArticleHow do you use gcc to generate assembly code in MIPS syntax?
Dev-C++ uses AT&T assembly, and I want to convert that in MIPS. I can't find the command for the Windows 10 (64bit) that does that. Linux for example uses mips-linux-gnu-g++ -march=mips32r2 -S...
View ArticleWhat is the gcc cpu-type that includes support for RDTSCP?
I am using RDTSCP to replace LFENCE;RDTSC sequences and also get the processor ID back so that I know when I'm comparing TSC values after the thread was rescheduled to another CPU.To ensure I don't run...
View ArticleWhy I am not able to free memory? Invalid free() / delete / delete[] / realloc()
I am trying to improve the ugly C code, which causes a memory leak. Valgrind points: ==19046== 1,001 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==19046== at 0x4C2FB0F: malloc (in...
View Article