How can I compile a C++ library statically with Bazel to use in Rust?
My goal is to get a .a static library on linux from the MediaPipe project, which is built with Bazel. To my knowledge, there is no bazel rule for doing so. I really don't want to integrate with Bazel -...
View ArticleOther ways to initialize empty character array in c/cpp
char arr[n] = ""; This works fine with gcc but with clang below error is seen : error: variable-sized object may not be initializedIs it fine using memset with '\0' ?
View ArticleTool to analyze size of ELF sections and symbol
I need a way to analyze output file of my GCC compiler for ARM. I am compiling for bare metal and I am quite concerned with size. I can use arm-none-eabi-objdump provided by the cross-compiler but...
View ArticleThe size of the function use nm tool
I used the command line nm --print-size --size-sort --radix=d abc.o and had a result like this:0000000001843744 0000000000019313 W _ZN4onnx15InternedString 0000000001843744 0000000000019313 W...
View ArticleCreating 2d arrays dynamically in C without malloc
I have written a small game in C, which has a board-like structure in the gameplay. So, I have used a 2d array of structures which contain many data elements like integer, bools, chars, etc. (let us...
View ArticleForce LTO inlining
I have object files containing moderately sized functions (approximately 256 FLOPs each, no loops) that are called from a .c file. I would like to force the inlining of these functions during Link-Time...
View Articlepango_font_description_from_string not found
I'm building a program which uses GTK+3 and pango. Most of it compiles fine apart from the last bit which builds the executable. The final command is:gcc -o z80sim main.c -Wall -Iz80 -Igui `pkg-config...
View Articlec++ ABI compatibility between gcc-4.4 and gcc-4.8
I've got a RedHat6 build platform which has gcc-4.4.7 installed and I've built a bunch of shared and static libraries on that platform.Now I want to build an app on the above platform which links...
View ArticleBuild Options When Building GCC From Source
I'm trying to build GCC from source, and I couldn't find a clear answer on how to do the following:control whether I run a debug or release mode buildcontrol the specific compiler to useI looked here...
View ArticleHow to edit a number which is at a specific location in a given file in C?
I have saved a list of number as 1 2 3 4 5 6 7 8 9 10 in the file INPUT.txt. and I want to edit a specific location (which is the 5th element here) and want to replace it by number 35. How can I do...
View ArticleWhy is this code 6.5x slower with optimizations enabled?
I wanted to benchmark glibc's strlen function for some reason and found out it apparently performs much slower with optimizations enabled in GCC and I have no idea why.Here's my code:#include...
View ArticleC local array not freed when using goto
Not sure i'm missing something about the use of goto:This doesnt work, ends in a segfault:for(long i = 0; i < 1000000000; i++) { LABEL_1: { int test[10]; goto LABEL_2; } LABEL_2: { int test[10]; } }...
View Articleassert() with message
I saw somewhere assert used with a message in the following way:assert(("message", condition)); This seems to work great, except that gcc throws the following warning:warning: left-hand operand of...
View ArticleSubtleties dealing with cross compilation, freestanding libgcc, etc
I have a few questions about https://wiki.osdev.org/Meaty_Skeleton, which says:The GCC documentation explicitly states that libgcc requires the freestanding environment to supply the memcmp, memcpy,...
View ArticleHow to get list of sub-targets which got hit in a makefile?
I have a makefile as follows,all: target1 @echo "$(USER)" target1: target2 @echo "$(HOME)" target2: @echo "$(SHELL)"If I execute make all, I will get some output as expected. But is there way to know...
View Articlestack smashing detected comes in ubuntu 16.04
Earlier in Ubuntu 14.04, I used compile a code (using gcc) and no such error used to come. But when I upgrade to 16.04, the same code is giving me this error:*** stack smashing detected ***: ./main...
View ArticleRenesas v850 toolchain for Ubuntu
I'm looking for a Renesas v850 \ rh850 toolchain for Ubuntu, preferably gcc based. Browsing the internet I couldn't find up to date information on how to get it. Any ideas where can I get it from?
View ArticleCan a c++ program have alternate output results every time you execute with...
I have framed an error into a question.I keep getting 2 output results alternating randomly(sometimes its 'KATE' and sometimes its 'Little Deepu',even though the input is same . can someone explain me...
View ArticleGCC 7, -Wimplicit-fallthrough warnings, and portable way to clear them?
We are catching warnings from GCC 7 for implicit fall through in a switch statement. Previously, we cleared them under Clang (that's the reason for the comment seen below):g++ -DNDEBUG -g2 -O3...
View ArticleGCC -T link option issue
I have compiled the project with arm-none-eabi-gcc to object with commandarm-none-eabi-gcc --specs=nosys.specs -mcpu=cortex-m7 -mtune=cortex-m7 -Os -g -gdwarf-2 -c $< -o $(@) currently I got the...
View Article