Skip to content
Advertisement

Tag: c++11

Fast byte copy C++11

I need to convert C# app which uses extensively bytes manipulation. An example: Basically BitConverter and Buffer.BlockCopy called 100s times per sec. There are several classes that inherit from the base class above doing more specific tasks. For example: What approach in C++ should I look into? Answer Best option, in my opinion, is to actually go to C –

pointer get wrong value in different thread

I am writing a piece of code to demonstrate the multi-threading share memory writing. However, my code gets a strange 0xffffffff pointer I can’t make out why. I haven’t been writing cpp code for a while. please let me know if I get something wrong. I compile with the command: g++ –std=c++11 shared_mem_multi_write.cpp -lpthread -g I get error echoes like:

Fedora 28 / GLIBC 2.27 libm.so.6 logf() and powf() c++

As I am sure other Fedora 28 users will know, the OS’s glibc was recently updated to glibc 2.27. Amongst many other things, 2.27 has added new implementations of logf() and powf(). This has caused my application to fail to run on distributions with an older glibc (Debian, for example). When the application is invoked on Debian, the following error

Where to find the source code of timespec_get?

The C11 standard provides the function timespec_get. If I run the example code on cppreference, or on my computer, it works: However, if I look at the sources of glibc here, the code is the following: Which… should not work… Which leads to the question: where is the source code of timespec_get that is actually called? Answer The timespec_get function’s

calling std::system with parameter containing space in double quotes

I need to call a linux std::system call with parameter than contain string with spaces. In order to process it correctly using argc / argv I want to pass it with double quotes. std::string cmdline = “myprogram -d “I am a sting”” ; if I cout this string I get good results. When I send it to std::system(cmdline) and look

Poco C++ Libraries: “Not found: mysql”

I am using poco-1.7.7 with MySQL. I am building with g++ on Ubuntu. Building, linking and running works fine. However, when a Data Session is created, an exception “Not found: mysql” is thrown: The mysql client is installed and is part of $PATH. Additional information: I am running Ubuntu using Docker. See below for Makefile. The same code can connect

add another timer on already running loop

Given the following program – The second timer handle is never run on the loop, since the loop is already running, and “Timer2 called” is never printed. So I tried stopping the loop temporarily after running it and then adding the second timer – But this again didn’t work, probably because the later lines won’t be executed after 1st loop

access order of std::atomic bool variable

I’ve a function that accesses(reads and writes to) a std::atomic<bool> variable. I’m trying to understand the order of execution of instructions so as to decide whether atomic will suffice or will I’ve to use mutexes here. The function is given below – I’ve read this page on cppreference which mentions – Each instantiation and full specialization of the std::atomic template

Advertisement