c++

How to avoid HDD thrashing

I am developing a large program which uses a lot of memory. The program is quite experimental and I add and remove big chunks of code all the time. Sometimes I will add a routine that is rather too memory hungry and the HDD drive will start thrashing and the program (and the whole system) will slow to a snails pace. It can easily take 5 ...

Preventing SQL injection in C++ OTL, DTL, or SOCI libraries.

I've been looking at all three of these database libraries, and I'm wondering if they do anything to prevent SQL injection. I'm most likely going to be building a lib on top of one of them, and injection is a top concern I have in picking one. Anybody know? ...

memory leak: unable to break on a memory allocation number

I'm trying to locate a memory leak issue. My project is an ATL based dialog project, that uses DirectShow and the standard library. I get a total of 45 memory leaks in my program, all 24 bytes each. I've #define'd _CRTDBG_MAP_ALLOC etc in my stdafx.h, along with DEBUG_NEW to get the file and line numbers for each of the memory leaks. ...

Building a project with CMake including other libraries which uses different build systems

I am working on an open source project which uses C for libraries, C++ for GUI and Cmake for managing build. This project is just started and have only couple of files. I can successfully generate makefiles on my linux development environment and on windows I can generate Visual Studio project files using CMake. All works well so far. A...

C++ Integer overflow problem when casting from double to unsigned int

I need to convert time from one format to another in C++ and it must be cross-platform compatible. I have created a structure as my time container. The structure fields must also be unsigned int as specified by legacy code. struct time{ unsigned int timeInteger; unsigned int timeFraction; } time1, time2; Mathematically the conv...

OpenCV: Getting and Setting Camera Settings

I have been searching around and can't find an example of how to get and set the camera capturing settings. For example the capturing resolution, fps, color balance, etc. I have only seen examples of how to change the settings when saving the captured video but I want to be able to find all the camera's capturing modes and choose which...

Whats the right approach for error handling in C++

One is to use C++ exceptions: try catch blocks. But freeing dynamic memory will be an issue when an exception is raised. Second is to use C style: errno variable Third is just to return -1 on error and 0 on success :) Which way should be chosen for a mid-size project and why? Any other better approach..? ...

Weird unresolved external errors in linked objects

Using Visual Studio 10 C++, I'm having weird link error. For some reason references to a global object won't link to that global object. It is telling me a symbol is undefined yet when I have it view the .cod file the symbol is right there plain as day. The error: FTShell.lib(ftcommodule.obj) : error LNK2001: unresolved external symbol...

casting LPCWSTR to LPCSTR

got this code from a website that helped me in creating buttons and stuff. the buttons work but for some reason im getting an compiler error with the creating a static. cannot convert from 'const wchar_t [5]' to 'char' cannot convert parameter 3 from 'char' to 'LPCWSTR' is there a simply way to fix this? i tried casting lyrics into a...

Whats wrong with this c++ reverse string function

void reverse (char s[]){ int len = strlen(s); int j = len - 1; for (int i = 0; i < j; i++,j--){ cout << s[i]; char ch = s[i]; s[i] = s[j]; //error line - giving exception, cannot write to the memory s[j] = ch; } } I am using Visual Studion 2008 and i can't understand whats the problem here .. :s .. I am out of C++ p...

Custom draw CTreeCtrl: how to add font strike through?

I have implemented custom draw for an CTreeCtrl in my MFC Smart Device program. I have successfully changed the color of specific nodes of the CTreeCtrl. I am now trying to understand how to get the default font used to draw text in the control so I can add a strike-through to the font for certain nodes. How would I go about getting t...

[Qt] getting the error: 'unavailable synchroneous data'

Hey guys, I'm getting this strange error in Qt while debugging .. Here's whats happening: I am debugging inside this function/method which is part of a class named Canvas. Now within this function, I should be able to access all of this class's variables, etc .. since the access request is coming from within the same class. However, when...

Variable and loops convertion from VB.NET to C++?

Is there any available tool for converting variable and loops declarations from VB.NET to C++? Thanks in advance ...

c++ rvalue passed to a const reference

I'm trying to understand exact C++ (pre C++0x) behavior with regards to references and rvalues. Is the following valid? void someFunc ( const MyType & val ) { //do a lot of stuff doSthWithValue ( val); } MyType creatorFunc ( ) { return MyType ( "some initialization value" ); } int main () { someFunc ( creatorFun...

How can i make a text box that changes input constantly?

So I want to create a text box "static if possible" that when my user interacts with the story game the text inside changes to accommodate his action. so im guessing i want a pointer to the char variable, but it seems that i cant figure out how to do this... can someone help me please. im thinking create the static box with a argument...

AIX 6.1 linker error

I'm trying to compile my application on AIX. It builds fine on Linux, Solaris x86 and Windows but this is the first time we've tried to build on AIX. I've managed to get to the point of linking all of the libraries together and I get the error message: Linking... ld: 0711-101 FATAL ERROR: Allocation of 96864 bytes failed in rout...

How to set a zmq socket timeout

I've got client and server applications using zmq in the ZMQ_REQ context. What I'm experiencing is that when the server component goes down or is unavailable, the client will wait until it is available to send its message. Is there a way to set a max wait time or timeout at the client level? ...

Compare matrices problem

I must multiply matrix by itself until the matrix in some degree would not be equal one of the preceding matrices. Then I need to get the values of degrees, in which the matrices are equal. The number of rows and columns are equal. Matrix is stored in a two-dimensional array. Values are 0 or 1. What is the best way to check for equality ...

[C++] Skipping Incompatible Libraries at compile

When I try to compile a copy of my project on my local machine, I get an error stating that it 's skipping over incompatible libraries. This isn't the case when I'm messing around with the live version hosted on the server at work [it makes perfectly there]. Various other sites have lead me to believe that this might be an environment ...

[Qt] Having difficulty in storing a QImage and then recovering it ..

Ok well I'm trying implement something similar to the 'undo' function in many image drawing programs .. The problem I'm having is this: I'm trying to make a backup copy of a QImage object in a QVector (which stores upto 10 latest QImage copies for backup purposes), and then try to retrieve these backups in another function. The issue is ...