c++

my program skips over a return statement

My program has this function: vector<itemPtr> Level::getItemsAt(const Point& pt) { vector<itemPtr> vect(items.size()); // copy all items at pt's position to vect remove_copy_if(items.begin(), items.end(), vect.begin(), boost::bind(matchesPosition<itemPtr>, _1, pt)); // upda...

Why does std::locale loc("en_US") throw an exception?

I attempting to instantiate a std::locale object with the US or GB-English locale string: std::locale loc("en_US"); or std::locale loc("en_GB"); Both of which throw a bad locale name runtime exception. Creating a locale using "" or "C" works fine, however I'm having trouble setting an individual country locale. The reason I'd...

GNU ld cannot find library which is there

The packages I'm toying with here are rather unknown, but nevertheless the problem is rather generic. Basically, I'm trying to compile Python module (called rql) with C++ extension. The extension uses external framework called gecode, which contains several libraries. I compiled gecode and installed locally. Now, let the output speak for...

Help with Asynchronous I/O

I have been doing a lot of searching and still can't seem to figure out how to fix my issue. I am writing a GUI program (in WinAPI so no MFC please) to communicate with another program (command line based). I am using anonymous pipes since everything is local (but perhaps named pipes would be better?) which then I use CreateProcess(); to...

using mat file in C++ program

Hi Please.. any one help me I have Mat file include struct of array for features vectors, I need to use this file in C++ program. How can I load this file in my C++ program? ...

public char * member of a class/struct inaccessible?!?!?!po

Code snippet to follow. I have a struct (example code has class, tried both, same effect) that will store a number of char *. I made a constructor for the class that initializes most of them to = ""; Upon attempting to modify that member of an instance of the class, strncpy et all report access denied. These functions even report acce...

gcc template error

why in the first line of this code: template <typename VectorType> std::string repr_vector_dynamic(const VectorType* vect) { std::stringstream strs; strs << "("; for (int i = 0; i < vect->size(); ++i) { if (0 != i) { strs << ", "; } strs << (*vect)[i]; } strs << ")"; return str...

converting a for loop to a std::for_each

I've got this for loop: std::vector<itemPtr>::iterator it; for(it=items.begin(); it!=items.end(); ++it) { investigators.addToLeaderInventory(*it); } I'd like to convert it to something like this: std::for_each(items.begin(), items.end(), investigators.addToLeaderInventory); However, that line doesn't compile...

Win32 -- how to manage my mouse hook thread

I have successfully gotten my low-level mouse hook code to work, but there are some behaviors I'm observing that I don't quite understand. Everything works fine if I spawn a thread which installs the mouse hook. When i no longer need it running, I let the thread get destroyed automatically as I exit the program, and I imagine I can easil...

How can I get a least recently used algorithm to work with multiple threads?

I'm using a memory pool to store image data in a ray tracer and I'm using a least-recently-used algorithm to deal with freeing blocks of memory. This works fine when there is only one thread. When I add more threads, the LRU code breaks. I'm using a linked list to store the history of which blocks have been accessed and this is the part ...

Learning OpenGL while practicing TDD (unit testing)

I have started a new game project, and have decided to learn and use OpenGL for it (project is being simultaneously developed on Windows and Linux). At the same time, I am also very interested in Test Driven Development, and am trying to put my best effort into writing my unit tests to lead design before any actual code. However, I thin...

Information on implementing game multiplayer?

I'm building a game and I'm looking for a good way to implement multiplayer. It is a sandbox game with Box2D physics. I was thinking of making it so the client only sends input to the server and receives which sprites to draw and where. Would this be a good idea? What might be ideal for a game with Physics like this? Thanks ...

OneOfAType container -- storing one each of a given type in a container -- am I off base here?

Hello everyone :) I've got an interesting problem that's cropped up in a sort of pass based compiler of mine. Each pass knows nothing of other passes, and a common object is passed down the chain as it goes, following the chain of command pattern. The object that is being passed along is a reference to a file. Now, during one of the s...

Problem with a custom drawn list view

I created a list view class that uses Custom Draw for its rendering. It all works well except that it doesn't render anything. I subclassed its parent window to catch the NM_CUSTOMDRAW notification as a WM_NOTIFY message. However, it appears that WM_NOTIFY is only triggered a few times during creation of the control and never again after...

Permanent Memory Address

With my basic knowledge of C++, I've managed to whip together a simple program that reads some data from a program (using ReadProcessMemory) and sends it to my web server every five minutes, so I can see the status of said program while I'm not at home. I found the memory addresses to read from using a program designed to hack games cal...

PIMPL and stack allocation

So I've been thinking about PIMPL and stack allocation. I've been writing a library and decided to use PIMPL to hide the private member of the class. That means I would have a class declared like this class Foo { private: class Handle; std::tr1::shared_ptr<Handle> handle; public: Foo(); }; It's pretty straight forward. But...

Error C2146: syntax error : missing ';' before identifier

The line in question is: extern BOOL logged_in; Here are my includes: #define _WIN32_WINNT 0x0403 // Very important for critical sections. #define WIN32_LEAN_AND_MEAN // Good to use. #pragma optimize("gsy", on) // Global optimization, Short sequences, Frame pointers. #pragma comment(...

sum of elements in a `std::vector`

What are the good ways of finding the sum of all the elements in a std::vector? Suppose I have a vector std::vector<int> vector with a few elements in it. Now I want to find the sum of all the elements. What are the different ways for the same? ...

How could I open a file, read 9 seperate letters, and pass them all to another function? I struggle with arrays! (c++)

The text document is TTT.txt ...in it is X X X O - X O O - I need my program to read each and then be able to pass it to a different part of it...HELP! ...

How can I guarantee full macro expansion of a parameter before paste?

I have a general macro: #define mSwitch( Root, Case ) Root##_Case_##Case #define mSpecialDisplay( what, Val ) mSwitch(mSpecialDisplay,what)(Val) #define mSpecialDisplay_Case_Int(Val) ...do stuff #define mSpecialDisplay_Case_Float(Val) ...do stuff ...more special cases how do I guarantee that the variable Case is fully expanded ...