x86 mfence and C++ memory barrier
I'm checking how the compiler emits instructions for multi-core memory barriers on x86_64. The below code is the one I'm testing using gcc_x86_64_8.3.std::atomic<bool> flag {false}; int any_value...
View ArticleFirebase cpp linking with clang++ android
I recently learnt that android is soon switching from gcc to clang and I compiled by download ndk 19.0 and the firebase 6.9.0. But when I try to build my project, I get a bunch of ~129 errors and I'm...
View Articleopencv compile with clang ok, with gcc not ok os x 10.9
I am on OS X 10.9, with opencv-2.4.8.2 installed. I am trying to compile a simple code:#include <stdio.h> #include <opencv2/opencv.hpp> using namespace cv; int main(int argc, char** argv )...
View ArticleGCC left shift overflow
The following little program is very awkward using GCC version 4.2.1 (Apple Inc. build 5664) on a Mac.#include <stdio.h> int main(){ int x = 1 << 32; int y = 32; int z = 1 << y;...
View ArticleDetermine gcc-toolchain version in clang++ preprocessor
According to cppreference, the gcc libstdc++ supports the parallelism TS. In layperson terms and for what's relevant for me that means #include <execution> works in g++ 9 and doesn't work in g++...
View ArticleComparing a bit to a boolean
Seemingly simple question: Say I have a set of flags, encoded in a uint16_t flags. For example, AMAZING_FLAG = 0x02. Now, I have a function. This function needs to check if I want to change the flag,...
View ArticleHow to use Cython on Windows 10 with python 3.8
I want to know how correctly convert py documents to C with help Cython But all the time a have some error.D:\Cython\test4>python setup.py build_ext --inplace running build_ext Traceback (most...
View ArticleCan I detect and change the current data alignment setting for structures in...
My question is based off a part of this wiki answer to the question of Why isn't sizeof for a struct equal to the sum of sizeof of each member?:"IMPORTANT NOTE: Both the C and C++ standards state that...
View ArticleCan't compile shared library under Windows due to undefined reference
I'm using the same waf script, both for Linux and for Windows, to compile a shared-library for a program (which is able to load shared libraries at run-time).To create this library I import some...
View ArticleI'm using Linux, compiling with gcc, getting error: warning: implicit...
I'm trying to write a simple edge detection program in c. I'm using Red Hat Enterprise Linux Server 7.7 (Maipo), and gcc version 4.8.5. This is the start of the code:#include <stdio.h> #define...
View ArticleBuilding and installing third party software [closed]
Apologies if I missed the forum since this isn't exactly a coding question, more of a point-me-in-the-right-direction plead. I'm tasked to install a framework from Github, but I'm not familiar with...
View ArticleCompiling C with JNI for Raspberry Pi 2 (wrong ELF class)
I am trying to compile basic C code with JNI for Rpi2. I was trying to do it directly in rpi with GCC. I have tried many different switches, but nothing is working and I am still getting:Java...
View ArticleVirtual function overloading in diamond hierarchy produces different results...
The following code produces different results on clang.#include <iostream> struct Dummy1 {}; struct Dummy2 {}; struct A { virtual void foo(Dummy1) { std::cout << "A"<< std::endl; }...
View ArticleAvoid the use of .data segment
Is there a way to avoid that the compiled code use the .data segment? Is it possible to write a C code and use compiler options to force everything to be in .text? The reason I ask is because I want to...
View Articlegcc compile error: cast specifies array type
The following code is perfect valid,int *ia = (int[]){1,3,5,7}; but when I compile the next line of code,char *p = (char[]) "abc"; gcc saystest.c:87: error: cast specifies array type It seems they are...
View ArticleCompile *.a to *.so
Maybe a stupid title, but I was not creative enough to find a better one. My Problem: I have a dynamic library that contains my core library and a guy library FoxToolkit So the *.so file contains, as...
View ArticleNot able to take input of numbers from notepad in my code [duplicate]
My code is:(Using Atom) Kindly NOTE all the errors have been removed but output is wrong. At the end of the question output is mentioned.#include<iostream> #include<fstream> using namespace...
View ArticleWhy is a switch not optimized the same way as chained if else in c/c++?
The following implementation of square produces a series of cmp/je statements like I would expect of a chained if statement:int square(int num) { if (num == 0){ return 0; } else if (num == 1){ return...
View ArticleAvoid OpenMP RTL mismatch if MKL and OpenMP are used in cmake
I stumbled upon a problem which I couldn’t immediately solve by reading the documentation of FindBLAS and FindOpenMP. Maybe someone here has a hint for me. Let’s say I have project which imports an...
View Articlehow to generate core file in docker container?
using ulimit command, i set core file size.ulimit -c unlimitedand I compiled c source code using gcc - g option. then a.out generated. after command./a.out there is runtime error .(core dumped) but...
View Article