Minimize number of absolute relocations

There is a Android-targeted dynamic library written in C++. Final binary contains a lot of absolute relocations to the same symbols, E.g. for __cxa_pure_virtual. readelf --relocs tells next: ... 00332fe4 00030502 R_ARM_ABS32 00000000 _...
more »

2017-08-19 22:08 (0) Answers

std::sort & comp - calling convention?

Windows targeted project, Visual Studio 2012 I'm trying to use std::sort to sort an array of struct pointers. The sorting is meant to be done from a GUID contained within the struct, and so I want to define a custom compare function for my sor...
more »

2017-08-19 21:08 (2) Answers

Catching Exceptions in Oracle on Solaris fails

In our code we trying to catch an exception. This code has been working fine for years with different architectures and operating systems (x86, x64, SuSe Linux 11 SP2, Oracle 11g, Oracle 12c). Now we also tried out Solaris 11.3 on x86/64 and Sparc wi...
more »

2017-08-19 14:08 (0) Answers

Creating class object in the game loop

I'm wondering how is the proper way to create objects of classes in the game loop once? For example I've Box, Sphere, Cyllinder classes and I want to create several objects at different time while the program is running and work with them in the futu...
more »

2017-08-19 02:08 (1) Answers

Platform dependent state of mt19937 in C++?

I want to save the state of the std::mt19937 random number generator in a C++ program, so that I am able to resume my program at a later stage at the same "randomness state". I also want to use my program on different platforms (Linux and Mac). Con...
more »

2017-08-19 02:08 (1) Answers

Inherited sprite not draw-able

In SFML I wanted to have a sprite but with other functions and variables so i decided to create a class that inherits the sprite class like this: 1. Player.hpp #pragma once #include <stdio.h> #include <SFML/Audio.hpp> #include <SFML/...
more »

2017-08-19 00:08 (1) Answers

c++ simple function dilemma

I am learning c++. Here is my problem: Simple "calculator" program: read two numbers and a sign, pass them to function calculate, which returns the value or error, if forbiden char input. I came up with two versions of my function and I don't know w...
more »

2017-08-18 19:08 (5) Answers

Remove input R object in C++ function environment

I have an Rcpp function inside an R function. The R function produces some object (say a large list) and feeds it to the Rcpp function. Inside the Rcpp function, I copy the R object's data to a number of C++ classes, and from now on the R object is p...
more »

2017-08-18 00:08 (1) Answers

Sorting with indices using sort in C++

In a previous question, an answer showed how to use lambdas to track original positions in an array and just sort the indices. C++ sorting and keeping track of indexes I want to sort the list but store the original indices. One approach is to sort...
more »

2017-08-17 14:08 (1) Answers

OpenCL files fail to compile on OS X

I have a quite large opencl file that compiles fine on both Windows and Linux Ubuntu but fails on MacOSX. The cvmcompiler process uses 100% of the CPU and never completes. The full code of the project is there: https://github.com/favreau/Sol-R and ...
more »

2017-08-17 12:08 (2) Answers

Declare object inside class header

In my one class, I need to declare some objects (timer objects) inside of the header file. class machine { public: machine(); private: timer buttonPressed; // this compiles timer buttonPressed(1000); //this does not c...
more »

2017-08-16 20:08 (0) Answers

C++ class function fails to change variables

When calling buildingname.damagebuilding(34) the currenthealth would only decrease temporarily, the first print prints 100 the second prints 66 but after calling damagebuilding again it's reset to 100 again. currenthealth isn't set anywhere else but ...
more »

2017-08-15 22:08 (1) Answers

C++ Override base member value

i have following code: class A { public: int foo = 0; }; class B: public A { public: int foo = 1; }; int main() { A *a = new B(); std::cout << a->foo; std::getchar(); return 0; } output: 0 why does B not overr...
more »

2017-08-15 06:08 (4) Answers

How do I use the mpi.h in XCode?

I have installed MPICH3.2 from the following the direction in given website http://mpitutorial.com/tutorials/installing-mpich2/ I downloaded the tar file and in Downloads/ directory and installed using terminal.I wanted to test if my program works ...
more »

2017-08-14 21:08 (2) Answers

C++ vector storing generic T type classes

I have a Foo class that expects T type values. I'd also like to store them in a vector. I've tried several methodologies, but didn't find any solutions. Please have a look at the source code below to get the idea what I'd like to achieve. #include &...
more »

2017-08-14 15:08 (1) Answers

class pointer method crashing program

I am trying to make a program that has two account balances, one for a go-card the other for a bank account. I have made a class for each, however when I try to call the debit method in the go-card class via a class pointer, my program crashes (it co...
more »

2017-08-14 07:08 (2) Answers

Generic lambda xcode 8.3.3

I was just trying to learn some features of lambda Tried one of the example provided here How does generic lambda work in C++14? auto glambda = [](auto a) { return a; }; But I don't know for some reason xcode complains about it auto not a...
more »

2017-08-13 20:08 (1) Answers

Find an entry of in a matrix of vector C++

I want find the element v[0][0]=1 v[0][1]=2 of the vector v with the use of lambda function and find of stl. #include <iostream> #include <algorithm> using namespace std; int main() { vector<vector<int>> v(3); v[0].r...
more »

2017-08-12 19:08 (1) Answers