c++

Missing symbol after compiling swig interface

Hi, Im trying to compile a php interface for my linux shared object and i have managed to get it to compile all right using the output from swig, however when i try and load the so it complains of a missing symbol: error: undefined symbol: zend_register_long_constant Now i have had a look at zend and it seems to be a php framework. I...

XML tree printer?

Is there a program that will print a nicely formatted tree from XML data? I am working on a B+ tree programming assignment for class and it would greatly help if I could visualize the tree. It wouldn't be too hard to output my internal data structure to XML (see below) if there was a program that would render it. ...

Using ShellExecuteEx and capturing standard in/out/err

I'm using ShellExecuteEx to execute a command in C. Is there a way to use ShellExecuteEx and capture standard in/out/err? Note: I don't want to use CreateProcess. ...

Lazy object creation in C++, or how to do zero-cost validation

I've stumbled across this great post about validating parameters in C#, and now I wonder how to implement something similar in C++. The main thing I like about this stuff is that is does not cost anything until the first validation fails, as the Begin() function returns null, and the other functions check for this. Obviously, I can achi...

Find nearest points in a vector

Given a sorted vector with a number of values, as in the following example: std::vector<double> f; f.pushback(10); f.pushback(100); f.pushback(1000); f.pushback(10000); I'm looking for the most elegant way to retrieve for any double d the two values that are immediately adjacent to it. For example, given the value "45", I'd like this ...

Visual Studio Compiler warning C4250 ('class1' : inherits 'class2::member' via dominance)

The following code generates warning C4250. My question is, what's the best solution to it? class A { virtual void func1(); } class B : public A { } class C : public A { virtual void func1(); } class D : public B, public C { } int main() { D d; d.func1(); // Causes warning } According to what I've read it should be possibl...

Destruction order of static objects in C++

Can I control the order static objects are being destructed? Is there any way to enforce my desired order? For example to specify in some way that I would like a certain object to be destroyed last, or at least after another static onject? Cheers, Gal ...

WAV compression help

How do you programmatically compress a WAV file to another format (PCM, 11,025 KHz sampling rate, etc.)? ...

What is your most useful C/C++ utility?

It seems that every project has an "utility" module with various code snippets used throughout other files and which don't fit any particular pattern. What utility classes, functions, and macros do you find most useful in your C/C++ projects? Please keep the entries small (under 100 lines) and give only one example per post. ...

What advantage does C++ have over .NET when it comes to to game development and apps like VirtualBox

This is an attempt to rephrase a question I asked earlier. I'd like to know why C++ seems to be the language of choice for certain thick client apps. The easiest example I can think of is video games and my favorite app VirtualBox. Please don't close this post I'm just trying to understand why this is the case. ...

Winform Not Displaying in Designer

I have a Managed C++ WinForm that suddenly stopped showing in the VS 2005 designer. The error it shows is Could not find type 'int'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built. I don...

Using an STL Iterator without initialising it

I would like to do something like this: container::iterator it = NULL; switch ( eSomeEnum ) { case Container1: it = vecContainer1.begin(); break; case Container2: it = vecContainer2.begin(); break; ... } for( ; it != itEnd ; ++it ) { .. } But I can't create and initialise an iterator to NULL. Is there some way I can do this? Ide...

C++ Why is this passed-by-reference array generating a runtime error?

void pushSynonyms (string synline, char matrizSinonimos [1024][1024]){ stringstream synstream(synline); vector<int> synsAux; int num; while (synstream >> num) {synsAux.push_back(num);} int index=0; while (index<(synsAux.size()-1)){ ...

boost::bind with functions that have parameters that are references

I noticed that when passing reference parameters to boost bind, those parameters won't act like references. Instead boost creates another copy of the member and the original passed in variable remains unchanged. When I change the references to pointers, everything works ok. My question is: Is it possible to get references to work, o...

My C++ object file is too big

I am working on a C++ program and the compiled object code from a single 1200-line file (which initializes a rather complex state machine) comes out to nearly a megabyte. What could be making the file so large? Is there a way I can find what takes space inside the object file? ...

Compilation error when calling _tcsstr and assigning to a wchar_t*

I am getting a compilation error when trying to build a C++ project which previously worked. The code follows: const wchar_t* pdest; pdest = _tcsstr(ConnStr, Name); The error follows: Error 10 error C2440: '=' : cannot convert from 'const char *' to 'const wchar_t I'm using Visual Studio 2008. The error message explains the prob...

Wrapping unmanaged c++ in a managed wrapper

I have an unmanaged C++ library. I would like to expose the functionality for .NET applications. There's one partucular function I am not sure how to handle: typedef void (free_fn*) (void*); void put (void *data, free_fn deallocation_function); The idea is that you pass dynamically allocated buffer to the function and supply a dealloca...

A C++ iterator adapter which wraps and hides an inner iterator and converts the iterated type

Having toyed with this I suspect it isn't remotely possible, but I thought I'd ask the experts. I have the following C++ code: class IInterface { virtual void SomeMethod() = 0; }; class Object { IInterface* GetInterface() { ... } }; class Container { private: struct Item { Object* pObject; [... other m...

Problem Linking Boost Filesystem Library in Microsoft Visual C++

Hello. I am having trouble getting my project to link to the Boost (version 1.37.0) Filesystem lib file in Microsoft Visual C++ 2008 Express Edition. The Filesystem library is not a header-only library. I have been following the Getting Started on Windows guide posted on the official boost web page. Here are the steps I have taken: ...

Is there any good example of http upload using WinInet c++ library

I cannot get my code to work :/ ...