c++

Problem with syntax for std::binary_function usage

I'm a newbie at using the STL Algorithms and am currently stuck on a syntax error. My overall goal of this is to filter the source list like you would using Linq in c#. There may be other ways to do this in C++, but I need to understand how to use algorithms. My user-defined function object to use as my function adapter is struct is...

Carbon or CF to list contents of a directory (OS X and C++)

How do I use Carbon or CoreFoundation (preferably the latter) to list the contents of a directory? ...

Where can I see printf output in an mfc applcation?

Where can I see printf output in an mfc application during debugging? Is there a "console" window I can view in the debugger? (Visual Studio C++ 6.0) Thanks. ...

Detect if dll is loaded into service

Is there a windows api to detect whether or not my dll is running in a system service or a normal user process? Previously I was looking at the current username and ignoring "SYSTEM", "LOCAL SERVICE" and "NETWORK SERVICE". But now I am seeing GetUsername return machine_name$ in cases where svchost gets run in certain situations befor...

How to draw on given bitmap handle (C++ / Win32)?

I'm writing an unmanaged Win32 C++ function that gets a handle to a bitmap, and I need to draw on it. My problem is that to draw I need to get a device context, but when I do GetDC (NULL), it gives me a device context for the WINDOW! The parameter for GetDC () is a window handle (HWND), but I don't have a window; just a bitmap handle. ...

boost threads mutex array

hello. My problem is, I have block matrix updated by multiple threads. Multiple threads may be updating disjoint block at a time but in general there may be race conditions. right now matrix is locked using single lock. The question is, is it possible (and if it is, how?) to implement an efficient array of locks, so that only portions...

C++ delete operator confusion

Possible Duplicate: ( POD )freeing memory : is delete[] equal to delete ? char* pChar = new char[10]; delete pChar; // this should not work but it has same effect as // delete[], WHY? // I know this is illegal, but why does it work? ...

'std::vector<T>::iterator it;' doesn't compile

I've got this function: template<typename T> void Inventory::insertItem(std::vector<T>& v, const T& x) { std::vector<T>::iterator it; // doesn't compile for(it=v.begin(); it<v.end(); ++it) { if(x <= *it) // if the insertee is alphabetically less than this index { ...

Am I failing to follow the standard?

If I have something like this: MyStruct clip; clip = {16, 16, 16, 16}; I get the following warning from the compiler: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x If I active -std=c++0x in the compiler, it does not give any warning. But I'm not sure if I am following the standard. So should I de...

May I take the address of the one-past-the-end element of an array ?

Possible Duplicate: Take the address of a one-past-the-end array element via subscript: legal by the C++ Standard or not? int array[10]; int* a = array + 10; // well-defined int* b = &array[10]; // not sure... Is the last line valid or not? ...

Problem With Setting Compiler Flags

I'm trying to configure my cross compiler (mipseb-linux-g++) to generate binaries with the MIPSI ISA. There is a flag for this "-mips1". I have this flag in my make file and for some reason g++ is still generating MIPSII instructions (which I assume is default?). Am I doing anything wrong? Here's my process flow: write c++ program ...

Windows Mobile Performance & DirectShow

Hi, Currently I'm building an application that is an image filter that should run in real-time. It's filter that transforms image captured from the camera and displays a transformed image just like the camera preview does. The problem that I'm having with this is that, the performance is critical to this app, as every captured pixel sh...

strange character "â" in cmake generated makefile errors

Terrible title, sorry. I used cmake to generate a makefile and I specified g++ as the C++ compiler and when I run the generated makefile using make or gmake I get all these compile errors and all my symbols have trailing â's on them. Any thoughts on what might be behind these mysterious â's? ...

How can I automate checking the menus for integrity in a C++ app?

In my C++ solution there are two projects : a SDI app and a MDI app. Both have quite a lot of menus, and I often make changes (add / delete / replace menus). Instead of checking for correctness myself (I'm error-prone, you know), I would love to have an automation for this. Ideally it would warn me for either not having a handler for s...

strlen() not working

Basically, I'm passing a pointer to a character string into my constructor, which in turn initializes its base constructor when passing the string value in. For some reason strlen() is not working, so it does not go into the right if statement. I have checked to make sure that there is a value in the variable and there is. Here is m...

Problems with Qt 4.6 in VS 2008

sys info : win xp SP3 , Microsoft Visual Studio 2008 Version 9.0.21022.8 RTM Microsoft .NET Framework Version 3.5 SP1 Qt Add-in 1.1.5 I installed Qt 4.6.3 from the site http://qt.nokia.com/downloads/windows-cpp-vs2008. Then I added the Add-in Qt 1.1.5 and configured the PATH variable. When I open a new QT project , default example wo...

Compare a value with all array elements in one statement

For example: if (value == array[size]) //if the value (unique) is present in an array then do something can this be done in one statement without having to call a function or a basic for loop statement? ...

How to delete a pointer after returning its value inside a function

Hi, I have this function: char* ReadBlock(fstream& stream, int size) { char* memblock; memblock = new char[size]; stream.read(memblock, size); return(memblock); } The function is called every time I have to read bytes from a file. I think it allocates new memory every time I use it but how can I free the memory once I ...

Why does this pointer point to nowhere?

I'm trying to add functionality to the v8sharp project and I'm having some issues (I'm not very good at C++ so I'm pretty sure the issue lies in my lack of C++ abilities rather than misusing v8.) Anyone in v8sharp we have this code v8value.cpp: v8sharp::V8FunctionWrapper^ V8ValueWrapper::WrapFunction(v8::Handle<v8::Value> value) { ...

JavaScript Standard Library for V8

Hi In my application, I allow users to write plugins using JavaScript. I embed V8 for that purpose. The problem is that developers can't use things like HTTP, Sockets, Streams, Timers, Threading, Crypotography, Unit tests, et cetra. I searched Stack Overflow and I found node.js. The problem with it is that you can actually create HTTP...