c++

Is there a way to do something to static members on process end?

I have a class that uses libxml2. It has static members which are used to hold context for a schema file and its parser. I'm using valgrind, and it's complaining that memory is not deallocated in connection with the schema context. This is because you need to free that memory yourself. However, since these context variables are stati...

Static library links in wxWidgets statically, but apps using my lib still require wxwidgets

Hopefully someone can help me out here. I'm using Visual Studio 2005 and creating a static library that links in wxWidgets statically. I have: compiled wxWidgets statically according to their guide included the lib directory in my "Additional Library Directories" property added all of the wxWidget libs in my "Additional Dependencies" p...

Handling of references in C++ templates

I currently have a function template, taking a reference, that does something in essence equivalent to: template <typename T> void f(T& t) { t = T(); } Now, I can call: int a; f(a); To initialize my variable a. I can even do: std::vector<int> a(10); f(a[5]); However, this will fail: std::vector<bool> a(10); f(a[5]); The re...

Call unmanaged C++ VS 6.0 MFC dll from C#

Hello, I have an unmanaged C++ MFC dll that was developed in VS 6.0. I would like to use it in my C# app. I'm trying to use PInvoke. Here is the C++ code: // testDll.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" extern "C" { BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_rea...

Writing a test case that checks for memory leaks in C++

NOTE: THIS IS NOT HOMEWORK IT IS FROM A PRACTICE EXAM GIVEN TO US BY OUR PROFESSORS TO HELP US PREPARE FOR OUR EXAM I'm currently studying for a programming exam. On one of the sample tests they gave us we have the following question: Suppose you have been given a templated Container that holds an unordered collection of objects. temp...

What's the result if I use delete p instead of delete [] p for an array?

Possible Duplicates: Why is there a special new and delete for arrays? ( POD )freeing memory : is delete[] equal to delete ? What's the result if I use delete p instead of delete [] p for an array? I met two answers for this problem. 1 only the first element will be freed. 2 there comes to a catastrophic end. My question is...

c++ boost regex which element was true

The answer to this may be a simple no, but here goes... I'm currently using the boost function regex_match to evaluate a string against a regex value. Instead of just returning T/F, is there a way to find out which element of multiple joined statements evaluated to true? For example: ^a$|^z$|^p$ a --> 0 z --> 1 f --> -1 ...

Dialog application with LISTBOX

I'm creating an S60 application that will have a main dialog with a listbox of 5 or so items. but i keep receiving a message : "application app1 closed" when trying to run the application on the emulator. This is my resource file (app1.rss)content : RESOURCE DIALOG r_dialog { flags=EAknDialogSelectionList; buttons=R_AVKON...

Are multiple conditional operators in this situation a good idea?

I just saw this block of code on the Wikipedia article on conditional operators: Vehicle new_vehicle = arg == 'B' ? bus : arg == 'A' ? airplane : arg == 'T' ? train : arg == 'C' ? car : arg == 'H' ? horse : feet;...

How to use HTTPS with HttpReceiveHttpRequest()?

I'm using the Windows HTTP API to process web service requests in C++ (not .NET) and everything works just fine for HTTP requests. When I change the URLs I'm expecting with HttpAddUrl to https://example.com:443/foo/bar my tests from Internet Explorer no longer connect. My code does not get called at all and the calls to HttpReceiveHttpRe...

Using stdout/stderr/stdin streams behind haskell's FFI

I'm developing a small haskell program that uses an external static library I've developed in C++. It accesses the lib through ghc's FFI (foreign function interface). Inside this library I would like to do some output to the console. However, it looks to me like the c++ side of things does not have a correct handle to stdout because outp...

Detecting application hang

I have a very large, complex (million+ LOC) Windows application written in C++. We receive a handful of reports every day that the application has locked up, and must be forcefully shut down. While we have extensive reporting about crashes in place, I would like to expand this to include these hang scenarios -- even with heavy logging...

Passing a reference of a base class to another function

Hello stack overflowers, Here is the problem i am facing, does anyone have solution? Class A: public class B { // I want to pass a reference of B to Function } void ClassC::Function(class& B) { //do stuff } ...

C# Child Process from Legacy C++ App Windowing Problems...

We have a c++ legacy application and have been extending it with c# applets that are invoked using COM from the parent c++ app. They bring up windows that are not modal. Moreover, I think these .NET windows are not proper children of the c++ application, since EnumChildWindows misses them, and EnumWindows finds them. One child-like beh...

Reading Pixels of Image in C++

How to open and read the pixels of an image in c++? Read them in the form of X, Y and to know the color. ...

Are there any Regression Tests coded in C/C++ to test all the functionality of CString (ATL/MFC)?

I am trying to do a comparison of CString from ATL/MFC to a custom CString implementation and I want to make sure that all the functionality in the custom implementation matches that of the ATL/MFC implementation. The reason we have a custom CString implementation is so that we can use it on *nix and Windows platforms. The interface is ...

How do I over-allocate memory using new to allocate variables within a struct?

So I have a couple of structs... struct myBaseStruct { }; struct myDerivedStruct : public myBaseStruct { int a, b, c, d; unsigned char* ident; }; myDerivedStruct* pNewStruct; ...and I want to dynamically allocate enough space so that I can 'memcpy' in some data, including a zero-terminated string. The size of the base struct...

Filling a Partially Rounded Rectangle with GDI

I have a rounded rectangle that I make like so dc.RoundRect(textBorder, CPoint(20, 20)); Later on I draw a line through it about 1/3 of the way down. dc.LineTo(textBorder.right, textBorder.top + 15); Now I would like to fill just the part above the line with a solid color. In other words I need to fill a partially rounded rectan...

Very weird errors when linking (LNK1000)?

Error 1 fatal error LNK1000: Internal error during IncrBuildImage MFC_Test MFC_Test Why do I get this weird error every 2nd time I compile? ...

split a string using find_if

Hi, I found the following code in the book "Accelerated C++" (Chapter 6.1.1), but I can't compile it. The problem is with the find_if lines. I have the necessary includes (vector, string, algorithm, cctype). Any idea? Thanks, Jabba bool space(char c) { return isspace(c); } bool not_space(char c) { return !isspace(c); } vector<s...