Why 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 ArticleError building Glib due to undefined reference in libffi
I am currently working on building Glib version 2.45.8 on CentOS 7 running on x86-64 targeting a custom distro based off Linux from Scratch running on x86-64. There is a problem linking with libffi...
View ArticlePrint Unicode characters in C, using ncurses
I have to draw a box in C, using ncurses;First, I have defined some values for simplicity:#define RB "\e(0\x6a\e(B" (ASCII 188,Right bottom, for example) I have compiled with gcc, over Ubuntu, with...
View ArticleValgrind Error: in use at exit: 72,704 bytes C++ Initialization List...
Issue:I have a weird issue that I wasn't expecting. I have a class called Answers and within the header is this:class Answer { char* aText; bool b_correct; public: Answer():aText(0){;} //default...
View ArticleDefault arm-linux-gnueabihf-gcc Architecture/CPU/fpu Flags
How can I print the used/default options for-march-mcpu-mfpu-mtunefor a specific cross compiler (arm-linux-gnueabihf-gcc)?
View Article-std=c++14 after -std=c++11 in my build command, which wins? [duplicate]
I have both options on in my Makefile, Basically, my Make file looks like this$OPT_FLAG := -O2 -std=c++11 $CXXFLAG += $(OPT_FLAG) -std=c++14 so actual build command is sth likeg++ -m64 ... -std=c++11,...
View ArticleWhen compile llvm 3.1, why get error: expected primary-expression before ‘>’...
For some reason, I need to install llvm 3.1 or llvm 3.0, but I'm getting this error when during make. [ 5%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o In file...
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 Articlenot found for architecture x86_64, macOS Sierra
Background:Yes, I know it is very easy using Brew! Already test and works!Now I'm experimenting with MacOS Sierra, and installing httpd-2.4.25.tar.gz enabling openssl.I don't have experience with...
View ArticleWhich C++ features does gcc-linaro-arm support?
I am looking for the gcc-linaro-arm counterpart to the this page here "C++ Standards Support in GCC" (https://gcc.gnu.org/projects/cxx-status.html#cxx17) ... I actually only need the info for linaro...
View ArticleCompound literal and designated initializer warning from GCC but not Clang
Compiling with gcc -std=c99 -Wextra this piece of code:#include <stdio.h> struct T { int a; int *b; int c; }; int main(void) { struct T t = {.b = ((int []){1, 1})}; printf("%d\n", t.b[1]); return...
View ArticleIncomplete definition when using struct in header file
When I try to compile this program without the struct in the functions.h and functions.c file, it works. But when using a struct, it doesn't work. How do I properly use structs with these .h and .c...
View ArticleHow to completely remove GCC on CentOS?
CentOS: I noticed I have two versions of GCC, one in /usr/bin/gcc (4.4.7) and /usr/local/bin/gcc (4.8). This causes a conflict.How can I completely remove/purge the 4.4.7? I tried to override but it...
View ArticleGmon.out is not created with -pg flag
I am using a library called amino. It is written in C. https://github.com/golems/aminoInstallation is successful, passes unit tests, works on demos as well. Installation commands are those shortly:...
View Articleunderstanding the __libc_init_array
I viewed the source code of __libc_init_array from http://newlib.sourcearchive.com/documentation/1.18.0/init_8c-source.html . But I don't quite understand what this function does. I know that these...
View Articlemake -j 8 g++: internal compiler error: Killed (program cc1plus)
When I deploy Apache Mesos on Ubuntu12.04, I follow the official document, in step "make -j 8" I'm getting this error in the console:g++: internal compiler error: Killed (program cc1plus) Please submit...
View ArticleEclipse "crossGCC"
I just downloaded the Eclipse IDE for C/C++ (on Window 7) and trying to create a simple new project. In the tool chains there are "Cross GCC", "Cygwin GCC" and "Microsoft Visual C++". I never heard of...
View ArticleWhy do the usual access control checking applies to names used to specify...
The C++11/14 standards state the following in note 14.7.2/12 [temp.explicit]:The usual access checking rules do not apply to names used to specify explicit instantiations. [ Note: In particular, the...
View ArticleGCC options for optimization on given CPU architecture
I am working on Nehalam/westmere Intel micro architecture CPU. I want to optimize my code for this Architecture. Are there any specialized compilation flags or C functions by GCC which will help me...
View ArticleHow to change text color and console color in code::blocks?
I am writing a program in C. I want to change the text color and background color in the console. My sample program is - #include <stdio.h> #include <stdlib.h> #include <windows.h>...
View Article