c++

Get Custom File Version Info from a Native binary using C#

I've got a bunch of native (C++) binaries that I want to scan and retrieve version information about from a C# console application. Using System.Diagnostics.FileVersionInfo I am able to get the actual version strings, company name, etc. However there is a "Build Date" string in there (which is shown by the Windows File Properties "Vers...

How do I compile a 64-bit native C++ DLL in VS 2008?

I'm trying to port a native ATL C++ in-proc COM server to 64 bit in Visual Studio 2008. I've opened the Configuration Manager, added "x64" platform. Now I have 6 configurations - 3 for Win32 that compile and link fine and 3 for x64 that compile fine, but make the linker emit the following error: \Debug64\Objects\common.obj : fatal error...

UBLAS Matrix Finding Surrounding Values of a Cell?

I am looking for an elegant way to implement this. Basically i have a m x n matrix. Where each cell represents the pixel value, and the rows and columns represent the pixel rows and pixel columns of the image. Since i basically mapped points from a HDF file, along with their corresponding pixel values. We basically have alot of empty p...

How can I tell reliably if a boost thread has exited its run method?

I assumed joinable would indicate this, however, it does not seem to be the case. In a worker class, I was trying to indicate that it was still processing through a predicate: bool isRunning(){return thread_->joinable();} Wouldn't a thread that has exited not be joinable? What am I missing... what is the meaning of boost thread::joi...

Is HSE_REQ_EXEC_UNICODE_URL just a slow operation when replacing the request entity body?

I have an ISAPI extension that does some processing on file uploads before they are passed to an ASP.NET application. I'm using the HSE_REQ_EXEC_UNICODE_URL mechanism in IIS 6.0 to replace the entire request entity body. This works, but it seems to be horribly slow with larger request bodies. Over the LAN if I upload a 12MB file normal...

Rotating a bitmap 90 degrees

I have a one 64-bit integer, which I need to rotate 90 degrees in 8 x 8 area (preferably with straight bit-manipulation). I cannot figure out any handy algorithm for that. For instance, this: // 0xD000000000000000 = 1101000000000000000000000000000000000000000000000000000000000000 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

c++ vector random shuffle part of it

Whats the best way to shuffle a certain percentage of elements in a vector. Say I want 10% or 90% of the vector shuffled. Not necessarily the first 10% but just 10% across the board. TIA ...

C++ implicit conversion to bool

In an effort to make my enums more typesafe, I've been using macro-generated overloaded operators to disallow comparing enums against anything but an identically typed enum: #include <boost/static_assert.hpp> #define MAKE_ENUM_OPERATOR_TYPESAFE(enumtype, op) \ template<typename T> \ inline bool operator op(enumtype lhs, T rhs) \ ...

How portable is casting -1 to an unsigned type?

The other day, I came across this construct: static_cast<size_type>(-1) in some example C++ code, which is likely (depending on the details of where size_type is from) to be equivalent to the following C: (size_t)(-1) As I understand it, it works based on the fact that the representation of -1 in twos complement arithmetic is 11111...

What is the most painless approach to insert an element in the middle of the std::vector

I want to be able to insert an element in the middle (or another location) in the vector without overwriting existing element. Say my vector has 3 6 9 10 and I want to insert 7 right after 6. How should it be done without causing issues? It's very infrequent operation so efficiency is not a problem here. Also, at this point, I cannot ...

Producing the fastest possible executable

I have a very large program which I have been compiling under visual studio (v6 then migrated to 2008). I need the executable to run as fast as possible. The program spends most of its time processing integers of various sizes and does very little IO. Obviously I will select maximum optimization, but it seems that there are a variety of...

Advance iterator for the std::vector std::advance VS operator + ?

I found myself writing the following a lot: int location =2; vector<int> vec; vector<int>::iterator it=vec.begin(); /..../ std::advance(it, location); instead of it= it + 5; what is the Preferred/Recommended way ? ...

STL or Qt containers?

What are the pros and cons of using Qt containers (QMap, QVector, etc.) over their STL equivalent? I can see one reason to prefer Qt: Qt containers can be passed along to other parts of Qt. For example, they can be used to populate a QVariant and then a QSettings (with some limitation though, only QList and QMap/QHash whose keys are s...

"Launch Failed. Binary Not Found." Snow Leopard and Eclipse C/C++ IDE issue.

Not a question, I've just scoured the internet in search of a solution for this problem and thought I'd share it with the good folks of SO. I'll put it in plain terms so that it's accessible to newbs. :) (Apologies if this is the wrong place -- just trying to be helpful.) This issue occurs with almost any user OS X Snow Leopard who trie...

String Undeclared In C++

I'm sure this is a really simple thing, but I haven't worked in C++ forever. 14 C:\Dev-Cpp\mainCurl.cpp `string' undeclared (first use this function) > #include <stdio.h> > #include <curl/curl.h> > #include <string> > #include <iostream> > > int main(void) { > string url("http://www.google.com"); // > system("paus...

Invoking makefile in the project root directory from subdirectory Emacs - C++

I have a makefile in the project root directory. If I am editing a file in a subdirectory, how do I invoke make from EMACS? M-x compile make will not work as it looks for the makefile in the current directory. But I have the makefile in the project root directory. Any thoughts? Edit As suggested, *make -f fullpath_to_makefile* did th...

How to create a MFC dialog with a progress bar in a separate thread?

My application may take a while to connect to a database. This connection is made with a single library function call, i.e. I cannot put progress updates in there and make callbacks or something similar. My idea was to create a dialog with a progress bar in a separate thread before connecting to the DB. This dialog will continually ch...

How to get the window handle of the desktop

The Windows API provides an API GetDesktopWindow( ) which returns the window handle But I tested with Spy++ and I find that the window handle of the desktop and the window handle of the "Windows Desktop" is not the same. As the "Windows Desktop" is a list view, do I need to do the following 1) HANDLE hWnd = GetDesktopWindow() ; 2) ...

Need a vector that derives from a vector.

Hi, Consider this simple code: class A { }; class V1: vector<A *>{ // my nice functions }; if I have a instance of V1, then any object derived from A can be inserted into the vector, ok here. Now, lets say I have two simple classes called B and C both derives from A; if I have a instance of V1, then both pointers of B and C can...

Comparing variables in two instances of a class.

Hello! i have what i hope is a quick question about some code i am building out.. basically i want to compare the variables amongst two instances of a class (goldfish) to see if one is inside the territory of another. they both have territory clases which in turn use a point clase made up of an x and y data-point. now i was curious to ...