c++

Tasks on Thread Building Blocks

Here is the example code: #include <iostream> #include <list> #include <tbb/task.h> #include <tbb/task_group.h> #include <stdlib.h> #include <boost/thread.hpp> using namespace tbb; long fib(long a) { if (a < 2) return 1; return fib(a - 1) + fib(a - 2); } class PrintTask { public: void operator()() { std::cout <...

Missing mingwm10.dll

I am coding a c++ project with Qt Creator. Everything is working fine (debug, release), but when I run the compiled .exe directly (go to exe file and run it) it says mingwm10.dll is missing. What can I do about this problem? ...

Why am I not getting events for a checkbox click in a treeview control?

In my MFC dialog, i have a tree view control with checkboxes. Clicking the checkbox does not raise the NM_CLICK nor the TVN_SELCHANGED events, which I had hoped it would do. How do I correctly determine when a checkbox is checked/unchecked in a tree view control? ...

Replacing existing raw pointers with smart pointers

Note: This may sound dumb. I have an application which uses raw pointers and there are lots of memory leaks in the application. Now my question is how easy would it be to replace the existing raw pointers with the smart pointers. And would just replacing them help is reducing memory leaks caused by not freeing dynamically allocated mem...

How to speed up g++ compile time (when using a lot of templates)

This question is perhaps somehow odd, but how can I speed up g++ compile time? My C++ code heavily uses boost and templates. I already moved as much as possible out of the headers files and use the -j option, but still it takes quite a while to compile (and link). Are there any tools out there which analyse my code and point out bottle-...

Prime numbers C++

Possible Duplicate: C++ Prime number task from the book Asked the question already but haven't gotten satisfiable answers; So can someone clear the following code on the level beginner could understand [I'm a beginner], it's from the book C++ From The Ground Up 3rd edition by Herbert Schildt int i, j; for(i=2; i<16; i++) ...

Dynamic linking and Python SWIG (C++) works in C++ fails in python

I have a library for which I have created a python wrapper using SWIG. The library itself accepts user provided functions which are in an .so file that is dynamically linked. At the moment I'm dealing with one that I have created myself and have managed to get the dynamic linking working... in C++. When I attempt to run it in python I ge...

Question about abstract factories and injection.

Hi, This is similar to one of my other questions, but different enough I think to warrant a new question. Basically I am writing a user interface, and my user interface has nodes that can be selected. When a node is selected, the user interface ends up with an abstract node base class "INode". From this I get a factory by doing node->...

pointer array and sizeof confusion

hey folks, why does this: char** pointer = new char*[1]; std::cout << sizeof(pointer) << "\n"; output 4? I have an array of pointers, but it should have length 1, shouldn't it? ...

How do I access return value of a Java method returning java.lang.String from C++ in JNI?

I am trying to pass back a string from a Java method called from C++. I am not able to find out what JNI function should I call to access the method and be returned a jstring value. My code follows: C++ part main() { jclass cls; jmethodID mid; jstring rv; /** ... omitted code ... */ cls = env->FindClass("ClassifierW...

C++ Function Pointer Syntax

I am trying to create a function in VC++ that takes a function pointer but I keep getting syntax errors. The declaration in my header file looks like this: void ApplyFuncToCellsInSelection(void(*func)(CPoint, *CSpreadWnd)); Here is the definition: void CSpreadWnd::ApplyFuncToCellsInSelection(void(*func)(CPoint, *CSpreadWnd)) { ... ...

Copy constructor problem

I tried to use copy constructor using statement: X y = X(); But copy constructor is not being called. I am using g++ 4.1.0. I set both X(const X&) and X(x&) constructor in the class. Is this supposed to work or I am doing some very basic problem in the code? My code for the class is class A { public: int i; A(int ii) { ...

Calling CoCreateInstance during service startup

I have a windows service, that makes several COM+ calls during initialization. On some systems this windows service causes a deadlock during startup. At least one service or driver failed during system startup The problem with calling CoCreateInstance during service startup is that it might require other services to startup. And th...

How to get really smooth moving objects using openGL

Dear reader, I'm working on an application where I draw a circular progress indicator which slowly gets "filled", here you can see a couple of images. I'm using intermediate mode and I'm only drawing this circular shape by drawing the vertices at each frame update (see code below). When the circle fills up the border line between the wh...

C++ variable declaration and initialization rules

Consider the following ways of declaring and initializing a variable of type C: C c1; C c2; c2 = C(); C c3(C()); C c4 = C(); Are all of these completely equivalent to each other, or can some of these differ depending on the exact definition of C? (assuming it has public default and copy constructors). ...

QT and CryptoPP: Converting QString/QChar to be accepted with CryptoPP

Hello, I want to make program that encrypts (later decrypts) user inputted string. Here is beginning for encryption: QString getData = ui->text->toPlainText(); //Data to process std::string output; //Result will be Base32 encoded string, so std::string is fine. Now, I have to convert QString to char* or std::string so it can be accept...

How to get a call stack backtrace? (deeply embedded, no library support)

I want my exception handlers and debug functions to be able to print call stack backtraces, basically just like the backtrace() library function in glibc. Unfortunately, my C library (Newlib) doesn't provide such a call. I've got something like this: #include <unwind.h printf("\t#%d: program counter at %08x\n", *depth, _Unwind_Get...

Moving ctor and moving dtor.

Hi, as I've asked in here and after a while I've agreed and accepted right answer to that question I was just thinking, if would it be useful to have something like "moving destructor" which would be invoked on moved object everytime we used move ctor or operator=. In this way we would have to specify only in move dtor what we want from...

C++ static template with external implementation

I have an a simple Registry pattern: class Object { //some secondary simple methods }; #define OBJECT_DEF(Name) \ public: \ static const char* Name() { return Name; } \ private: class Registry { struct string_less { bool operator() (const std::string& str1, const std::string& str2) { for(int i = 0; i < str1.size() && i < st...

Sort by proxy (or: sort one container by the contents of another) in C++

I have a set of data which is split into two arrays (let's call them data and keys). That is, for any given item with an index i, I can access the data for that item with data[i] and the key for that item with keys[i]. I cannot change this structure (eg, to interleave keys and data into a single array), because I need to pass the data ar...