c++

can we get the penultimate exception that occurred from an mdmp or hdmp in windbg

Hi, I got a crash dump (both mdmp and hdmp) for my application (written in C++) captured using dr. watson. After analyzing the dumps through windbg, I concluded that the crash had occurred in the catch() itself :) What I need to know is what exception caused the the failure in the first place i.e. I need that penultimate(last but one...

C++ Thread Safe Integer

Hello everyone, I have currently created a C++ class for a thread safe integer which simply stores an integer privately and has public get a set functions which use a boost::mutex to ensure that only one change at a time can be applied to the integer. Is this the most efficient way to do it, I have been informed that mutexes are quite ...

Calls to singleton library

I have a singleton class, and I will compile it as a library static(lib) or dynamic(dll). Is it guaranteed that calls to same file in a machine always refer to same and unique instance in both cases? Edit: What if a process loads two different library and different functions from these libraries want to use instance of singleton class....

templated method on T inside a templated class on TT : Is that possible/correct.

I have a class MyClass which is templated on typename T. But inside, I want a method which is templated on another type TT (which is unrelated to T). After reading/tinkering, I found the following notation: template <typename T> class MyClass { public : template<typename TT> void MyMethod(const TT & param) ; } ; For st...

Any way to profile code for cache behavior? (Windows / C++)

Hi all, as the title says I'd like to somehow get the cache behavior of my code. I'm running Windows 7 64-bit edition, compiling on Visual Studio 2008 Professional Edition, compiling C++ code. I understand that there's Valgrind under Linux, but are there any free alternatives I could use, or methods otherwise? Thanks! ...

Serializing struct containing char*

I'm getting an error with serializing a char* string error C2228: left of '.serialize' must have class/struct/union I could use a std::string and then get a const char* from it. but I require the char* string. ...

C++ Static Initializer - Is it thread safe

Usually, when I try to initialize a static variable class Test2 { public: static vector<string> stringList; private: static bool __init; static bool init() { stringList.push_back("string1"); stringList.push_back("string2"); stringList.push_back("string3"); return true; } }; // Implement ...

Why typedef char CHAR

Guys, having quick look in Winnt.h I have discovered that there is a lots of typedefs and one of them is for example CHAR for a char. Why? What was the purpose of these typdefs? Why not use what's already there (char, int etc.)? Thank you. ...

C++ - Efficient container for large amounts of searchable data?

Hello, everybody! I am implementing a text-based version of Scrabble for a College project. My dictionary is quite large, weighing in at around 400.000 words (std::string). Searching for a valid word will suck, big time, in terms of efficiency if I go for a vector<string> ( O(n) ). Are there any good alternatives? Keep in mind, I'm en...

C++ application as a service with high performance

I need to provide a C++ application as a service. Client of the service and the service can be on the same machine or distributed on different machines based on the load. This application takes a ~2KB string as input and returns almost similar size of string after some processing. Turnaround time for the client should be really quick. Wh...

How do I build boost examples with bjam?

Boost library is full of examples and tests and I would like to build them using bjam if possible. How do I build boost examples with bjam? PS. I wasn't able to locate proper documentation for this option. ...

How (if needed) to free dynamic memory when marshaling CString from C++ to C#?

I have CString cs on C++ side and IntPtr ip on C# side which contains value of cs through marshaling mechanism. Then, I simply get needed String as Marshal.PtrToStringAnsi(ip) and everything works fine, but I am wondering should I and if should, how can I delete unmanaged memory occupied by ip, i.e. cs? ...

How to extract ALL typedefs and structs and unions from c++ source

I have inherited a Visual Studio project that contains hundreds of files. I would like to extract all the typedefs, structs and unions from each .h/.cpp file and put the results in a file). Each typdef/struct/union should be on one line in the results file. This would make sorting much easier. typdef int myType; struct myFirstStruc...

How i can send an HttpRequest from C++

Im using DataServices and OData protocol, i need to generate Get, Post, Delete, and Update from a c++ aplication. how i can do this? the easiest way ?? ...

Complex error handling

I've got a particularly ornery piece of network code. I'm using asio but that really doesn't matter for this question. I assume there is no way to unbind a socket other than closing it. The problem is that open(), bind(), and listen() can all throw a system_error. So I handled the code with a simple try/catch. The code as written in...

Detect if an assembly is available

I'm implementing an installer in Java, that is supposed to download and install an application for non-privileged users in Windows (from XP and up). The application is written in C++, and depend on the usual VC runtime-libraries (msvcm90.dll and friends). In order to save bandwidth, I want to avoid downloading the VC redistributables if...

c++ euclidean distance

This code compiles and runs but does not output the correct distances. for (int z = 0; z < spaces_x; z++) { double dist=( ( (spaces[z][0]-x)^2) + ( (spaces[z][1]-y)^2) ); dist = abs(dist); dist = sqrt(dist); cout << "for x " << spaces[z][0] << " for y " << spaces[z][1] << " dist is "<< dist <<...

Multiple Producers Single Consumer Queue

I am new to multithreading and have designed a program that receives data from two microcontroller measuring various temperatures (Ambient and Water) and draws the data to the screen. Right now the program is singly threaded and its performance SUCKS A BIG ONE. I get basic design approaches with multithreading but not well enough to ...

Type to use as template parameter to compare double values

I got this n-dimensional point object: template <class T, unsigned int dimension> class Obj { protected: T coords[dimension]; static const unsigned int size = dimension; public: Obj() { }; Obj(T def) { for (unsigned int i = 0; i < size; ++i) coords[i]=def; }; Obj(const Obj& o) { for (unsigned int i = 0; i < size; ++i...

Windows Build System: How to build a project (from its source code) which doesn't have *.sln or Visual C++ proj file (*.vcproj)

I'm facing this problem. So, I need to build the support libraries (zlib, libtiff, libpng, libxml2, libiconv) with "Multithreaded DLL" (/MD) & "Multithreaded DLL Debug" (/MDd) run-time options. But the problem is there is no direct way . I mean there is no *.sln / *.vcproj file which I can open in Visual C++ and build it. I'm aware with...