c++

Best bignum library to solve Project Euler problems in C++ ?

Hi, I am still a student, and I find project Euler very fun. sometimes the question requires calculations that are bigger than primitive types. I know you can implement it but I am too lazy to do this, So I tried few libraries, MAPM :: very good performance, but it provides only big floats, with the possibility to check if it is an i...

Detecting stale C++ references in Lua

I'm lead dev for Bitfighter, a game primarily written in C++, but using Lua to script robot players. We're using Lunar (a variant of Luna) to glue the bits together. I'm now wrestling with how our Lua scripts can know that an object they have a reference to has been deleted by the C++ code. Here is some sample robot code (in Lua): if...

How to find the global function?

I have a function name called setValue, used in many classes. Also, i have a global function by the same name. When i press C-], it goes to arbitrary setValue function. How do i directly jump to the global setValue function? It is really pain to use tnext every time to find if the function global. ...

How to use 16bit heightmaps with Ogre3d and PhysX

I'm using Ogre3D and PhysX. When I load a terrain from an 8bit height map, it looks normal on Visual Debugger. Look at first image: http://img44.imageshack.us/gal.php?g=44927650.jpg But when I save the height map as a 16bit image, I get what you see on second image. Here's the code, thats works normal with 8bit PNG: mSceneMgr->s...

c++ compilation error.

Following code is giving compilation error in visual studio 2009. #include <iterator> #include <vector> template <class T1, class T2 > class A { public: typename std::vector<std::pair<T1,T2> >::iterator iterator; std::pair<iterator, bool > foo(const std::pair<T1 ,T2> &value_in); }; can anyone throw some light on it? Here is ...

How do I declare template function outside the class declaration.

#include <iterator> #include <map> #include <vector> template <class T1, class T2> class A { public: typedef typename std::vector<std::pair<T1,T2> >::iterator iterator; std::pair<iterator, bool > foo() { iterator aIter; return std::pair<std::vector<std::pair<T1,T2> >::iterator, bool >(aIter ,false); } }; T...

Books to refer for learning OOP through C++

I am looking for a book which can teach OOP concepts using c++ . Could you guys please suggest me some books. ...

Select() system call in threads?

Hi all, I am reading data from multiple serial ports. At present I am using Custom signal handler (by setting sa_handler) to compare and wake threads based on file descriptor information. I was searching for a way out to have individual threads with unique signal handlers, in this regard I found that select system call is to be used. N...

Adding a QT GUI to a Dynamic Library

Greetings overflowers. I am trying to add a GUI to to an existing project. More specifically to a plugin that is loaded as a .so file (or when compiled on win32 a .dll) The project has its own threading implimentation already to deal with portability. I know that QT has its own cross platform threading model but it would be preferable ...

Callback unmanaged code from managed C#

Bit of a history lesson here. I'm working on a legacy C++/MFC application and am trying to start a incremental modernization by pushing components written in C# (WinForms and later WPF). I'm stucking using .Net/1.1 and VS/2003 for many reasons which are impossible to resolve in the near future. Currently, as a proof of concept, someth...

SetFilePos error Photoshop Format plugin

I'm writting a photoshop plugin. Im currently trying to write code to save my data to file, however any attempt to do so is resulting in SetFilePointer returning -1. What to do!!!! OSErr SetFPos (int32 refNum, short posMode, long posOff) { long moved = SetFilePointer((HANDLE)refNum, posOff, NULL, posMode); if (moved != posOff) ...

How to check if a file has been opened by another application in C++

I know, that there's the is_open() function in C++, but I want one program to check if a file hasn't been opened by another application - is there any way to do it using standard library? EDIT - Clarified in the answers that this is for a Linux application. ...

What is the difference between pointer and array in the following context?

#include <cstring> int main() { char *pName = new char[10]; char dummy[] = "dummy"; strcpy(pName + 0,dummy);//how this is different from -->this works strcpy(pName[0],dummy);//this one...--> error C2664: 'strcpy' : //cannot convert parameter 1 //from 'char' to 'c...

validate xml schema using msxml parser

I want to validate an XML file against an XML Schema file. It is a simple xml file. does not include namespace etc. I want to do this in c++, using MSXML 6.0. Can anyone provide me the guidance to do this Thanks ...

Implementing a thread-safe, generic stack in C++ on linux

Hi All, In a recent interview, I was asked to implement a thread safe generic (i.e.template based) stack in C++, on linux machine. I quickly came up with the following (It may have compilation errors). I got through. The interviewer probably liked something in this implementation. Maybe the design part :) Here are a few problems that th...

Help for Boost.Statechart bug

Any ideas how to fix this? using 1.39_0 on ubuntu 8.10 w/g++ 4.3.2 In the following statechart, the phrase "BUGGY" is printed three times. One would expect the event would only trigger one "BUGGY". In the case of the project I am working on, I cannot return discard_event() as I need the event to reach multiple states (usually deep in a...

Reading from a file not line-by-line

Assigning a QTextStream to a QFile and reading it line-by-line is easy and works fine, but I wonder if the performance can be inreased by first storing the file in memory and then processing it line-by-line. Using FileMon from sysinternals, I've encountered that the file is read in chunks of 16KB and since the files I've to process are...

Where do I find a comparison of different STL containers complexity (performance)?

I googled quite a while in order to find out a comparison that shows the differences in complexity for all STL-Containers on insert/push erase/pop etc. I did not find any. Also not in all of my STL Books. Any hint? I know some rules of thumb of course. But where is a definition? ...

C++ How to read in objects with a given offset?

Now I have a file with many data in it. And I know the data I need begins at position (long)x and has a given size sizeof(y) How can I get this data? ...

Getting status message of successful executed SQL command?

I wrote a little C++/MFC application that allows me to connect to an ODBC database and execute SQL statements. I'm using SQLGetDiagField / SQLGetDiagRec to display meaningful error messages to the user in case of any errors. Is there a way to receive and disply the database confirmation messages ("table created", "role set", "user dropp...