C: pass a 2D array as a function argument and get the results stored in the...
Short: How can I pass a 2D array as a function argument and get the results stored in the argument address?Longer: I have code (below) which calls, from main() an initialization function and then...
View Articlestd::remove_if GCC implementation isn't efficient?
From another question here there seems to be evidence, that GCC's implementation of std::remove_if doesn't provide equally efficiency compared to the following implementation:'raw homebrew'...
View ArticleWhy does gcc add extra vmovdqa64 instructions with _mm512_dpbusds_epi32?
g++ is generating extra move instructions and I'm not sure why. Godbolt linkThis is happening around the _mm512_dpbusds_epi32 intrinsic. The instruction computes 8-bit dot products then adds them to a...
View Articleonly want a subset of the -Weffc++ warnings in gcc
I find some of the -Weffc++ warnings quite helpful (return-type of post-increment) and others not so much (absence of initialization of a member in a constructor). My first instinct would thus be to...
View ArticleSegmentation fault in allocating a large array in C
I intend to allocate a large array of size 1073741824 (equivalent to 1GB e.g.) and then read from it randomly but i get segmentation fault (core dumped) for only defining the array as i checked which i...
View ArticleDoes it provide any benefits to simultaneously use __attribute__ ((pure)) and...
I am optimizing a c program and I would like to know if it does make any sense to use __attribute__ ((pure)) and static inline both in the same function declaration?
View ArticleHow to include libraries with CIL Merge without merging the libraries
i want to know if there something special args like -l -L, like just link for gcc recognize theres a code from some library. But i want like, merge 3 files into one, but not merging the libraries too.
View ArticleHow to properly compile multiple files using GCC compiler and .o files with -o?
I'm trying to compile multiple files using the GCC compiler through the command prompt.I'm using this commands to compile them:gcc tokens.c main.c -c to create the .o files; and using gcc tokens.o...
View ArticleWhy do we need both read and write barriers?
Why do we need to define two types of barriers with the same implementation?For example, this code from io_uring in Linux:#if defined(__x86_64) || defined(__i386__)#define read_barrier() __asm__...
View ArticleWhy does the LIBRARY_PATH variable redundantly use "/../../" for locating...
I was analyzing gcc -v main.c -Wl, --verbose, when I realized a few of the paths mentioned in the LIBRARY_PATH variable were laughably redundant (assuming ../ refers to the parent...
View ArticleWhy doesn't GCC raise an error when I don't link libm explicitly? [duplicate]
I have referred to the following posts:Why do you have to link the math library in C?Why do I have to explicitly link with libm?All of them suggest I need to link libm explicitly with my program. But I...
View ArticleBash script error "undefined reference to sin" [duplicate]
I am writing a bash script with the purpose of creating a static library for C code and creating an executable. The C program itself works fine, the problem I'm having is that when I run my current...
View ArticleWhy was the implement of __pool_alloc_base in...
when I read pool_allocator in STL, I found that many functions of the __pool_alloc_base class are implemented in gcc/libstdc++-v3/src/c++98/pool_allocator.cc, why is that designed? Why not put the...
View ArticleHow do I know if std::map insert succeeded or failed?
I have a map in a multithreaded app mapping a class called uuid to pointer.What I want to know if an insert operation succeeded for failed.e.g._mymap.insert(hint, MyMap::value_type(entry.uuid,...
View ArticleHow _xabort(status) in HTM works?
I used _xabort(status) function in my code, in order to release the buffer in cache. I check the transaction whether it's successful, if the transaction success, I use _xend(), otherwise I use...
View ArticleHow to check for TSX support?
My current attempt:/**simplified from * https://software.intel.com/en-us/articles/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family **/#include...
View ArticleHow to use variable defined in one binary into another binary in C
We have two cores in microcontroller. One CM0+ and another CM7. Therefore we can't build single binary (executable) output because instructions sets are different for both cores. However, there is...
View ArticleLightGBM Image Not Found after Mac install
I installed the lightgbm package with pip (version 10.0.1) to my Python lib (version 3.6.3) on macOS Sierra (version 10.12.6), along with the dependencies found in the documentation, including...
View Articleweird format output when i print a memory address in c
When I try this C code that prints the memory address of three variables:int a = 45;float b;char c;printf("Address of a: %p \n", &a);printf("Address of b: %p \n", &b);printf("Address of c: %p...
View ArticleWhat is the significance of sbss2/sdata2?
I am working with PPC microcontroller (e200z4 specifically) using GCC based compiler. The PPC EABI support small data allocation if we define a variable whose size less than defined number (my case is...
View Article