c++

Application disappears after starting - C++ linking managed code dll

Hello, we have a problem with our applications. We have recently upgraded our toolchain to Visual Studio 2010 and friends, it all works fine on Windows Vista + Windows 7 developer machines and Windows 7 customer machines. (all x86) Today we did a first installation to a client PC running Windows XP SP2 x86, and all applications linking ...

[C++] Is it possible to use threads to speed up file reading ?

Hi there, I want to read a file as fast as possible (40k lines) [Edit : the rest is obsolete]. Edit: Andres Jaan Tack suggested a solution based on one thread per file, and I want to be sure I got this (thus this is the fastest way) : One thread per entry file reads it whole and stocks its content in a container associated (-> as ma...

Possible to call a managed DLL from unmanaged C++?

Is it possible to call CLR DLL (one for example which is made with C#) from Undamaged C++ code? I need a DLL that is not managed to call into it somehow, maybe even via some proxy C++ process that is built with C++ / CLI? ...

"Right" way to deallocate an std::vector object

The first solution is: std::vector<int> *vec = new std::vector<int>; assert(vec != NULL); // ... delete vec; An alternative is: std::vector<int> v; //... vec.clear(); vec.swap(std::vector<int>(vec)); The second solution's a bit of a trick --- what's the "right" way to do it? Update: I'm aware that the destructor will be called on...

Calculating toolbar icon width

I am building an RDP client and I have toolbar that shows the running applications, same as the Windows toolbar. I need to support dual monitors, so my questions are 1) How do I detect that there is more than one monitor and 2) Is there a formula for calculating the width of the icons on the toolbar? I know that at the start, the width...

What's the best way to write to more files than the kernel allows open at a time?

I have a very large binary file and I need to create separate files based on the id within the input file. There are 146 output files and I am using cstdlib and fopen and fwrite. FOPEN_MAX is 20, so I can't keep all 146 output files open at the same time. I also want to minimize the number of times I open and close an output file. How ...

How to send stream data via Bluetooth from an iPhone/iPod Touch to a Windows C++ application?

Hello, I need to develop an iPhone/iPod Touch application that creates a server to send some data stream (characters or bytes) to a Windows C++ application via Bluetooth. I'm thinking of creating a TCP connection, but don't know where to start. What iPhone API should I use do to something like this? Does anyone knows some code examples...

Interview question about virtual functions in C++

I was asked this crazy question. I was out of my wits. Can a method in base class which is declared as virtual be called using the base class pointer which is pointing to a derived class object? Is this possible? ...

Create a modifiable string literal in C++

Is it possible to create a modifiable string literal in C++? For example: char* foo[] = { "foo", "foo" }; char* afoo = foo[0]; afoo[2] = 'g'; // access violation This produces an access violation because the "foo"s are allocated in read only memory (.rdata section I believe). Is there any way to force the "foo"s into writable ...

Combine Video and Audio Streams (Qt, OpenCV, PortAudio,libsnd?)

Hey everyone, I was wondering, how would I combine recorded audio and video into one if I have them in separate files? Preferably using OpenCV and PortAudio/libsnd. Thanks in advance. ...

Find missing number in sequence in set or list

If a std::set or std::list contains a sequence of natural numbers (1, 2, 3..). would there be a function in standard library to find the missing number? ...

undefined reference and strange content of static library

Hey, I'm a real gcc newbee so excuse me if this is a silly question. I want to use opencv in android and therefore try to compile it into a static library that get's used in the android ndk build process to build a shared library that I intent to use for my android app. The build of the statc library works fine, but when building the sh...

Strange GCC 'expected primary expression...' error

Possible Duplicate: Templates: template function not playing well with classs template member function template <typename T> struct A { template <int I> void f(); }; template <typename T> void F(A<T> &a) { a.f<0>(); // expected primary-expression before ‘)’ token } int main() { A<int> a; a.f<0>(); // Thi...

Problems with system() calls in Linux

I'm working on a init for an initramfs in C++ for Linux. This script is used to unlock the DM-Crypt w/ LUKS encrypted drive, and set the LVM drives to be available. Since I don't want to have to reimplement the functionality of cryptsetup and gpg I am using system calls to call the executables. Using a system call to call gpg works fi...

XML parsing design using xmlpp and C++

I would like to use an xml format similar to the following: <CONFIG> <PROFILE NAME="foobar"> <PARAM ID="0" NAME="Foo" CLASS="BaseParam"/> <PARAM ID="2" NAME="Bar" CLASS="StrIntParam"> <VALUE TYPE="STRING">some String</VALUE> <VALUE TYPE="INT">1234</VALUE> </PARAM> </PROFILE> </CONFIG> CONFIG contains a list...

Recording Audio with OpenAL

I've been comparing various audio libraries available in C++. I was wondering, I'm kind of stuck starting with OpenAL. Can someone point out an example program how to record from a mic using OpenAL in C++. Thanks in advance! ...

Deleting a element from a vector of pointers in C++.

I remember hearing that the following code is not C++ compliant and was hoping someone with much more C++ legalese than me would be able to confirm or deny it. std::vector<int*> intList; intList.push_back(new int(2)); intList.push_back(new int(10)); intList.push_back(new int(17)); for(std::vector<int*>::iterator i = intList.begin(); i ...

Meaning of int(0) in int *pi = new int(0); ?

int *pi = new int(0); What's the significance of 0 here? Does it mean integer array of length 0? ...

C++ & C#, how to create wrapper dll in C++ for C# to call instance function in C++ dll?

Received an unmanaged C++ dll with instance functions which need to be called from my C#. need to write a wrapper C++ dll to bridge the C# and original C++ dll as suggested by experts here. it is new to me and want to learn from you. Header file of the original C++ dll likes this: class EXPORT_MACRO NB_DPSM { private: string sFi...

Looking for a script to convert multiline "block" comments in C/C++ to single line comments.

A simple find/replace will not work for code commented out like this: ex: /* templine1 templine2 templine3 */ Got any ideas? ...