Inhibit error messages for unused static functions?
In C code, if a function is used exclusively within a file, it's good practice to declare it to be static.But sometimes I define a function to be static but don't actually use it (yet), in which case...
View Articlenm shows the .so lib has the defined function, ld cannot find it [duplicate]
I'm working on an arm64 box.nm shows that my liblib1.so file has the defined function foo_incremented, ld cannot find it.~/code/pack/inlib$ nm -D --demangle --defined --extern-only...
View ArticleCopy elision possible if returning parameter?
Consider a function that takes an object by value, performs some operations on it and return that object, for example:std::string MyToUpper (std::string s){ std::transform(s.begin(), s.end(),...
View ArticleHow static modifier works in C?
I am trying to understand how the "static" modifier works in C, I went looking for its meaning and everything I found seemed a bit vague.It is a modifier to allow the values of a variable to exist...
View ArticleHow to print a function with prinf()?
So, i've this code, but i dont know how to print result of a function foo()#include <stdio.h>void foo(int arr[]){ int *sum = 0; int product = 1; for(int i = 0; i < sizeof(*arr); i++){ sum +=...
View ArticleDetermine if a process exists from its Process ID
I want to know in my program if a process with a certain ID exists. I implemented the following function to achieve that, which checks if /proc/<PID>/maps exist. However, I notice that even If I...
View ArticleUsing a static_cast on non-pointer related types
I discover this compiler trick and I cannot find a name for. Have you any idea?On an Intel processor, I can cast a variable from its base class to an inherited class. It works with MSVC, gcc and clang...
View Articleany equivalent of -fshort-enums in __attribute__ or #pragma?
I'd like to specify some but not all enum types as short-enums. Therefore, the compiler option -fshort-enums seems not the best choice.
View Articlehow to compile a c++ with a specific gcc version
I want to compile a program using gcc 4.8, but my default version is 9 something. I dont want to change my default version, I just want to compile this one program with gcc 4.8.I've tried the following...
View ArticleIf you use a newer gcc than the one that comes with your distro, are system...
My question specifies the version numbers of my scenario, but I'm interested in a general to the question.I'd like to use gcc 11 on Alma Linux/Red Hat 8 (identical ABI), which come with gcc 8, in order...
View Articlegcc.exe: error: Cocoa: No such file or directory gcc.exe: error: unrecognized...
[I am writing a code for heatmap on an image but I was encountered with this error I guess -the -framework option is unique to Apple platforms, as are the Cocoa, IOKit, and CoreVideo frameworks. The...
View ArticleSwallowing comma in variadic macros on compilers that do not recognise ##
I need to write a variadic macro in C which must take zero or more arguments.In gcc, that can be achieved by adding "##" after the comma, e.g. ,##____VA_ARGS____ as answered in Variadic macros with...
View ArticleConverting a gcc command to conan / cmake based build
I am using the modern conan method for compiling. I am cross compiling an application and am trying to figure out how to convert my existing gcc command to conan / cmake solution.Here is the gcc...
View ArticleWhich types on a 64-bit computer are naturally atomic in gnu C and gnu...
NB: For this question, I'm not talking about the C or C++language standards. Rather, I'm talking about gcc compiler implementations for a particular architecture, as the only guarantees for atomicity...
View ArticleDealing with __attribute__ in MSVC
I was wondering what the best way to deal with code containing GCC's __attribute__ extension when using MSVC. Is the following a safe way of dealing with this:#define __attribute__(x) /* blank - should...
View ArticleCompiler flags which make reverse engineering harder
Recently I read that using specific compiler flags can prevent or make reverse engineering much more complicated. I'm using those flags-s -O3 -Os -fdata-sections -ffunction-sections -fvisibility=hidden...
View ArticleCompiling a software with GTK which has no configuration script
I bumped into green, a PDF viewer for the Framebuffer. I would like to compile it, but I am not having much success, although I have installed all the dependencies...The error I am getting...
View Articlegcov and gcovr: no .gcno files are generated after compiling
I am trying to get code coverage in my unit test project in windows system.DescriptionAfter compiling with -fprofile-arcs -ftest-coverage, I found out the execution file is generated and works fine....
View ArticleMantissa size of double variable compile with GCC in Intel® Atom™ [duplicate]
I'am runing a C++ software with double variables. My platform is upboard with an Intel® Atom™ x5-z8350 (1.92 GHz). The OS is Ubuntu server 18.04 and I compile the software with GCC 7.5.0.I compile my...
View ArticleC++ gcc does associative-math flag disable float NAN values?
I'm working with statistic functions with a lot of float data. I want it to run faster but Ofast disable NAN (fno-finite-math-only flag), which is not allowed in my case.In this case, is it safe to...
View Article