c++

Need Help Tracking Down EXC_BAD_ACCESS on Function Entry on MacOS

I have a program that gets a KERN_PROTECTION_FAILURE with EXC_BAD_ACCESS in a very strange place when running multithreaded and I haven't the faintest idea how to troubleshoot it further. This is on MacOS 10.6 using GCC. The very strange place that it gets this is when entering a function. Not on the first line of the function, but th...

What is the simplest way to asynchronously communicate between C++ and C# applications

I have a C++ application that needs to communicate to a C# application (a windows service) running on the same machine. I want the C++ application to be able to write as many messages as it wants, without knowing or caring when/if the C# app is reading them, or even if it's running. The C# app be able to should just wake up every now and...

Problematic vector return value - not really updated?

I'm having this weird problem: when my program reach this method: //Returns the transpose matrix of this one RegMatrix RegMatrix::transpose() const{ RegMatrix result(numCol,numRow); int i,j; for(i=0;i<numRow;++i) for(j=0;j<numCol;++j){ result._matrix[j][i] = _matrix[i][j]; } return result...

Why would connect() give EADDRNOTAVAIL?

I have in my application a failure that arose which does not seem to be reproducible. I have a TCP socket connection which failed and the application tried to reconnect it. In the second call to connect() attempting to reconnect, I got an error result with errno == EADDRNOTAVAIL which the man page for connect() says means: "The specifie...

How to bring another window forward that is not owned by the program

Hi, I'm really struggling to find a way of bringing forward another programs window. For example, I use FindWindow to find the handle of Notepad. I then try to bring the window forward using SetWindowPos(hWnd, 0,0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE); But it just doesnt work!! ShowWindow doesnt either! Can you please hel...

OpenCV - cvExtractSURF is causing a memory leak?

Hello OpenCV'ers, I am using the OpenCV function: cvExtractSURF but I am finding a major memory leak. Has anyone successfully implemented this call? My code is as follows: IplImage *cvImage = [self CreateIplImageFromUIImage:image grayscale:YES]; CvMemStorage* storage = cvCreateMemStorage(0); CvSeq *objectKeypoints = 0; //CvSeq *objec...

capture video from a built-in camera programatically

Hi, I was wandering how could capture video from the built-in camera of my netbook, under Linux, ubuntu. The programming language could is not an issue (but I prefer Java or the old school c) Thanks in advance for your answers, Gian ...

check if std::map contains a key without doing insert?

The only way I have found to check for duplicates is by inserting and checking the std::par.second for false, but the problem is that still inserts something if the key is unused whereas I more want is as a map.contains(key); function. Thanks ...

Big-O notation Help

while (n >= 1) n /= 2; I am unable to get the Big-O notation for this ...

Trick Windows To See Second Monitor

Hi there, is there anyway to trick windows into thinking that a second monitor is connected to the computer, even if there isnt one? Example: Laptop also has an external screen connected into it. The external screen is the primary screen. When the screen is disconnected the laptop becomes primary even if the external screen is reconne...

Why doesn't unary_function define operator()?

I was just looking for a handy base class for a set of functors to be based on taking and int and returning void. Thinking to use std/functional the functors are basically going to be unary_function<int,void> with operator(). Why is virtual result_type operator()(const argument_type& _Left) const = 0; not defined on the unary_function...

How do I test for user input for equations?

I have an equation with 4 variables, I am prompting the user to enter each one of these variables, and then the program decides based on what variables are entered, which variables it needs to solve for. For instance, given variable a and b, I need to solve for b and c. I am trying to come up with a way for the program to decide which va...

Optimizing 1D Convolution

Is there a way to speed up this 1D convolution ? I tried to make the dy cache efficient but compiling with g++ and -O3 gave worse performances. I am convolving with [-1. , 0., 1] in both directions. Is not homework. #include<iostream> #include<cstdlib> #include<sys/time.h> void print_matrix( int height, int width, float *matrix){ ...

Transform a list of pointers to base class

I have a design where I have a std::list of base pointers that I'd like to transform into a parallel list that adds behavior. The problem I'm having is that the object that I'm trying to use to do the transform doesnt know what the actual types are when it is invoked. It's quite possible that I'm missing something subtle and that there ...

How do i change my merge algorithm to accept different arguments in c++?

The original code i wrote uses these arguments: int m = size of sorted list 1 int n = size of sorted list 2 int A[] = sorted list 1 int B[] = sorted list 2 int C[] = merged list of 1 and 2 I was asked to add this code to an existing file that uses these different arguments: IntVectorIt start1 IntVectorIt end1 IntVectorIt start2 ...

Update and multiple console windows

Hello; I want to write a simple c++/c console app, to show my process 1% 2%. for now, i print it line by line like "finsihed 1%" "finished 2%" and etc how can i just update percentage x% without printing a new line? and i want to open two console windows one show messages one show the process as above. how do i open another console ...

C++ Struct in array, help!

Hello - I have an iPhone app that used to use an array of several thousand small objects for its data source. Now, I am trying to make it use C++ Structs, to improve performance. I have written the struct, and put it in "Particle.h": typedef struct{ double changeX; double changeY; double x; double y; }ParticleStruct; The...

Do virtual functions have to be public?

Here is the way I have my base class working: class AguiWidgetBase { //variables AguiDockingEnum dockingStyle; std::string text; AguiRectangle clientRectangle; AguiColor tintColor; AguiColor fontColor; std::map<int,int,CmpIntInt> children; //private methods void zeroMemory(); virtual void onPaint...

QVariant to QObject*

Hi, I'm trying to attach a pointer to an QListWidgetItem, to be used in the SLOT itemActivated. The pointer I'm trying to attach is a QObject* descendant, so, my code is something like this: Image * im = new Image(); // here I add data to my Image object // now I create my item QListWidgetItem * lst1 = new QListWidgetItem(*icon, seri...

Fastest way to communicate between c++ and c#

We are building a new vision inspection system application. The actual inspection system needs to be c++ for a number of reasons. For that system we will be using Boost & Qt. For our UI, we are currently looking at using WPF/C# for the UI and SQL based reports. The complicating factor that UI has to run both local on the same box as ...