How to check if a given file descriptor stored in a variable is still valid?
I have a file descriptor stored in a variable say var. How can I check whether that descriptor is valid at a later stage? fdvar1= open(.....); fdvar2 = fdvar1; // Please ignore the bad design .... //...
View ArticleUsing the malloc function once initializes all uninitialized variables with a 0
The malloc function is not supposed to initialize any value to any variable it is used on, like the calloc function does. Why then do I keep getting the initialized value of every other varibale to be...
View ArticleExtern (global) variable not optimized out
Why does not GCC compiler optimize out variable foo entirely?it can reason that it will never return from an infinite loop and thus there is no possibility of this variable being used in any other...
View ArticleInternal Compiler Error: Segmentation Fault
I am getting the following error every time I try to build or make a package:In file included from /usr/include/gz/math7/gz/math/AxisAlignedBox.hh:25, from...
View ArticleGCC: how do I export (selected methods and) the vtable / typeinfo of a class...
I have this class in a shared library:class Interface { int m_ref;public: FOO_EXPORT virtual ~Interface(); virtual void foo() = 0;protected: void ref() { ++m_ref; } bool deref() { return --m_ref; }};//...
View ArticleWhy doesn't GDB show line numbers or function names?
I was trying to use GDB to troubleshoot a segfault in code I'm writing. GDB does not show line numbers or function names when I use the backtrace command. Here's a short sample program that illustrates...
View ArticleError: format: No such file or directory when I use c++ 20
I want to use <format> lib in my program to format the output#include <format>// matrix displaytemplate<typename T>void algebra::display(const algebra::MATRIX<T> &matrix) {...
View ArticleLink against import lib or dll?
I find I can link against a dll directly using Mingw g++.g++ -shared -o hello.dll hello.cppg++ -o world world.cpp hello.dllI used to link against the import lib of dll. What are the differences?
View Articlecompiling C program with gcc; Cannot open output file _.exe: no such file or...
I just started trying to program in C and I've downloaded all kinds of IDE's and compilers and nothing seems to be working. Cygwin keeps giving me this error when i try to compile my...
View ArticleForcing gcc to use /usr/gnu/bin/ld or /usr/gld rather than /usr/ld on Solaris...
I am trying to build libffi-3.4.5. The README file states that I must use GNU as and ld. On Solaris 11.3, these are either /usr/gas (or /usr/gnu/bin/as) and /usr/gld (or /usr/gnu/bin/ld). Short of...
View ArticleClass template static field initialization different results on GCC and Clang
Consider the following C++ code example:#include<iostream>class B {public: int val; B(int v):val(v){ std::cout<< val << "\n"; }};template<typename T>class A {public: static B...
View ArticlePractices for evaluating different linker outputs of STM32-code [closed]
I want to learn about programming an STM32 without ready-made startup-code and linking to improve my understanding of these crucial steps and to not be dependent on automatic code generation by ST. The...
View ArticleMSVC equivalent of __attribute__ ((warn_unused_result))?
I'm finding __attribute__ ((warn_unused_result)) to be very useful as a means of encouraging developers not to ignore error codes returned by functions, but I need this to work with MSVC as well as gcc...
View ArticleWhen inlining a C function, can an optimizing compiler dereference a pointer...
Consider the following code:int y = 1;int* p = &y;inline int f(int x) { return x + x;}int g(void) { return f(*p);}In this code, there is one explicit dereference.Is a C compiler allowed to...
View ArticleCompile nftables examples
how to compile one example source code of nftables archive ?> sudo apt-get source libnftnl11> cd libnftnl-1.2.1/examples/> ls -l Makefile.am nft-chain-get.c nft-ct-expectation-get.c...
View ArticleError: make: *** No rule to make target `.f90', needed by `.o'. Stop
I'm trying to run a case for the software [ExoPlaSim] (https://github.com/alphaparrot/ExoPlaSim) on my MacBook.While the software is built primarily for Linux, it can run on Mac according to the...
View Articlesetup script exited with error: command 'x86_64-linux-gnu-gcc' failed with...
When I try to install odoo-server, I got the following error: error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1Could anyone help me to solve this issue?
View Articlelibzimg: AddressSanitizer: SEGV
I would like to see a JPEG resized by half with libzimg (aka z.lib).This is my code snippet:#include <stdio.h> // fopen, fread, fwrite, fseek, ftell, rewind, perror#include <stdlib.h> //...
View ArticleCompile error: "g++: error trying to exec 'cc1plus': execvp: No such file or...
When I compile C/C++ program with popen in php... I got this error:g++: error trying to exec 'cc1plus': execvp: No such file or directorybut if I run php code in shell.. it works fine..in Arch...
View ArticleUndefined Function in Shared library but not in object files
I have a shared library that when put through a nm call shows a undefined symbol for strerror@@GLIBC_2.2.5.However, when I go through all object files that this shared library was generated from, and...
View Article