How to export a symbol to a shared library in nasm?
I have the following:BITS 64__NR_getuid equ 102global sys_getuidsection .textsys_getuid: xor eax, eax mov al, __NR_getuid syscall retThis is compiled with:nasm -f elf64 -o getuid.o getuid.asmld -shared...
View ArticleHow to create a static library with g++?
Can someone please tell me how to create a static library from a .cpp and a .hpp file? Do I need to create the .o and the .a? I would also like to know how can I compile a static library in and use it...
View ArticleUse libgcc/compiler-rt altrenative with GCC/Clang
I am writing small low-level runtime library for fun.According to the libgcc website, low-level runtime library are libraries that compilers generates calls to its routines whenever it needs to perform...
View ArticleWhen cross-compiling for an ARM embedded target using GCC, is it reasonable...
I have a build for an ARM embedded target that is developed using eclipse and GCC toolchain release 12.2-rel1.I have set up a build in TeamCity that runs in a Linux-based Docker container, also using...
View ArticleWhy Xcode C compiler does not display properly some of the ASCII table...
I'm developing a program in C using Xcode.To be practical let's take the following code#include <stdio.h>int main () { printf("%c",3);}It's supposed to display the hearts character but it...
View ArticleHow is this c function decrementing my counter?
I have the following code:int i;for(i=0;i<2;i++) { ... printf("i = %d\n",i); rtdb_pull(rtdb, buf, &ncenter); printf("i = %d\n",i); ...}When I run it, it goes through just fine while i=0, but as...
View ArticleWhy is [static 1] not used everywhere in C?
I saw a Video about modern C programming, and one topic was that when you use [static 1] with a parameter, it indicates to the reader and the compiler that a pointer should never be NULL.You would use...
View ArticleIs there a way to install gcc in OSX without installing Xcode?
I've googled the hell out of it, and it seems like there is no way to install gcc on OS X without installing Xcode (which takes at leats 1.5GB of space). All I need is gcc and none of the other junk...
View ArticleHow to hint to GCC that a line should be unreachable at compile time?
It's common for compilers to provide a switch to warn when code is unreachable. I've also seen macros for some libraries, that provide assertions for unreachable code.Is there a hint, such as through a...
View ArticleError during Gromacs2024.2 installation: srot & strsm
I was trying to install GROMACS following the installation guide from the GROMACS webpage (https://manual.gromacs.org/documentation/2024.2/install-guide/index.html) but after running:sudo make...
View ArticleHow to print garbage values in c using loop [closed]
When I run the following program it prints a garbage value:#include <stdio.h>int main() { int a; printf("%d\n", a); return 0;}But when I run this code that was intended for printing out ten...
View ArticleSTM32 ARM GCC Toolchain CMake target_compile_features no known features for...
Our project is using STM32 GCC ARM Toolchain, using STM32 CMake toolchain file (gcc-arm-none-eabi.cmake) which sets the CMAKE_C_COMPILER_ID and CMAKE_CXX_COMPILER_ID to GNU.When lines like this are...
View ArticleHow does GCC optimize this `switch`
Today I discovered that GCC does some amazing magic for optimizing switches in this code:StairsType GetStairsType(uint8_t tileId, uint8_t dlvl){ if (dlvl == 0) return StairsType::Part; if (tileId ==...
View ArticleHow to Install nvcc on CentOS7? [closed]
I'm on CentOS7 for legacy reasons, and I get the following error:Could NOT find CUDA (missing: CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRSCUDA_CUDART_LIBRARY)Clearly, I need to install the nvcc executable...
View ArticleLinking shared library without also having to link dependencies
If I have a library called libfoo.so, and it depends on other libraries:libfoo.so -> libbar.so libsomething.so libother.so -> libstuff.soI now have code I want to link against libfoo.so. Is it...
View ArticleHow to leverage the [*]printf format type specification warnings?
As we all know and love (or hate), GCC has the capability of issuing warnings when you attempt to use the printf() family of functions with mismatched type specifications. In our code, we have a number...
View ArticleHow to make g++ (avr-g++) output error line number and column?
i believe -g turn on debug information output:09-19 19:31:34.788: INFO/System.out(24948): /data/data/app/sdk/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections...
View ArticleCan't compile fortran on MacOS Monterey: ld: unsupported tapi file type...
I am facing an error whenever I try to compile fortran code:% gfortran Testing_Fortran.f90 -o Testing_Fortranld: unsupported tapi file type '!tapi-tbd' in YAML file...
View Articlegcc thumb2 inline assembly for fixed point conversion
I would like to write some gcc inline assembly for armv7em on Cortex-M7 to perform conversion between floating point numbers and fixed point numbers. ARM provides the vcvt instruction with #fbits to...
View ArticleHow can I ignore GCC compiler 'pedantic' errors in external library headers?
I recently added -pedantic and -pedantic-errors to my make GCC compile options to help clean up my cross-platform code. All was fine until it found errors in external-included header files. Is there a...
View Article