Compare 16 byte strings with SSE
I have 16 byte 'strings' (they may be shorter but you may assume that they are padded with zeros at the end), but you may not assume they are 16 byte aligned (at least not always).How to write a...
View ArticleIs short circuit evaluation a language feature in C/C++ or compiler...
I'm wondering if short circuit evaluation oflong param = 0;if ( functAWithSideEffects(¶m) || funcBWithSideEffects(¶m) )Can be relied on. For example, if funcAWithSideEffects returns...
View ArticleHow to declare 16-bits pointer to string in GCC C compiler for arm processor
I tried to declare an array of short pointers to strings (16-bits instead of default 32-bits) in GNU GCC C compiler for ARM Cortex-M0 processor to reduce flash consumption. I have about 200 strings in...
View ArticleProper way to create unique_ptr that holds an allocated array
What is the proper way to create an unique_ptr that holds an array that is allocated on the free store? Visual studio 2013 supports this by default, but when I use gcc version 4.8.1 on Ubuntu I get...
View ArticleWhen initializing a structure with the brace notation, does GCC...
Does gcc zero the 3 padding bytes after c.b ?struct { int a; char b;} c = { 1, 2};
View ArticleWhy gcc place a large constant array to ".rwdata" section rather than...
/* 0xFFFFFFFF * 256*/#define test_256X0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, ... 0xFFFFFFFFAfter compiling, the const array is placed in ".rwdata" section rather than ".rodata" section, and I...
View ArticleCython Compiled EXE needs Python Installation to RUN
I have compiled my python code (in Windows) with the following cython and gcc commands:-cython --embed -o hello.c hello.pygcc -municode -mthreads -Wall -O -IC:\Python37\include -LC:\Python37\libs...
View ArticleTARGET_OS_IPHONE and ApplicationTests
Why doesn't this code work when compiling an ApplicationTests unit test bundle?#if TARGET_OS_IPHONE #import <Foundation/Foundation.h> #import <UIKit/UIKit.h>#else #import...
View Articlewhat happened if store with memory_order_acquire
as we know:load with memory_order_acquire,store with memory_order_releaseHowever, I found with gcc4.8.2, open -O2, a compile error throwed, /usr/include/c++/4.8.2/atomic:199:9: error: invalid memory...
View ArticleIs it possible to write a _Static_assert in GCC/GNU C that would verify the...
Suppose that I have the following definitions:#include <stdbool.h>#include <stdint.h>#define ASSERT(cond) _Static_assert(cond, #cond)typedef union { struct { bool bit0:1; bool bit1:1; bool...
View ArticleObjcopy symbols are mixed or invalid in executable
As a simple example of my problem, let's say we have two data arrays to embed into an executable to be used in a C program: chars and shorts. These data arrays are stored on disk as chars.raw and...
View ArticleHow to make incomplete array/struct initialization an error or warning?...
If we define an array/struct like this:int a[5] = { 1, 2, 3, };struct b { int c; int d; } e = { 1, };or even:int a[5] = { 1, 2, 3 };struct b { int c; int d; } e = { 1 };we get no error from C compiler...
View ArticleHow do I create a static library with GCC compiler optimization?
I have a function to compute dot product in C++. I want to compile this function with -O3 compiler optimization. Rest of the codes in my codebase are compiled with -O0. To do this, I have created a...
View Articleerror: initializer element is not constant when initializing a structure by a...
When I compile the the following code I geterror: initializer element is not constantIt does compile in Windows (MinGW) but not in Linux.Structuremy_multiboot_header has to be initialized at compile...
View Articlesegmentation fault (core dumped) gcc ubuntu
I was trying to make a simple function to make a group of number that user enters them, using pointer of pointer but i keep getting this error and its hard to tell where the problem is, if there any...
View ArticleC (gnu11): Nested function segfaults
I use C11 with the gnu extensions (--std=gnu11). Given the following code with nested functions:#include <stdio.h>typedef int (int_f)();void print_f_res(int_f f) { printf("f() = %d\n", f());}void...
View ArticleHow can I install a specific version of GCC and g++ on ubuntu 20.04?
I am trying to build LFS and I need to downgrade my gcc version from 9.3.0 to 9.2.0? How can I do it?
View ArticleNVCC: "__builtin_ia32_kmov16" is undefined
CUDA Version: 10.0GCC Version: 6.5.1#include <immintrin.h>int main() { __builtin_ia32_kmov16 (0); return 0;}Build command:/usr/local/cuda-10.0/bin/nvcc -std=c++11 --verbose...
View ArticleGIMPLE insertion
I want to insert a GIMPLE_COND from the GCC API. What is the best approach for doing this from a plugin? Should this done before or after the CFG has been created. I made a plugin that gets called...
View ArticleSet the default GCC to Xcode Command Line Tools
How can I ensure that gcc points to a particular compiler? Can I make a permanent symbolic link to the xcode version of gcc?I have several versions of the gcc compiler installed on my system, including...
View Article