c++

Strange char* compile error?

Hello everyone, Anything wrong with my code below? I got the compile error! typedef unsigned char BYTE; void foo(char* & p) { return; } int main() { BYTE * buffer; // error C2664: 'foo' : cannot convert parameter 1 from 'char *' to 'char *&' foo ((char*)buffer); return 0; } Thanks in advance, George ...

Get bytes from a std::vector<bool>

I have something like the following, and after populating it with a arbitrary number of bits, I need to get the bytes to write out to a file. I don't see a way to do this and it seems useful, so I must be missing something. Any idea's? std::vector<bool> a; a.push_back(true); a.push_back(false); a.push_back(false); a.push_back(true); a...

Temp file that exists only in RAM?

I'm trying to write an encrpytion using the OTP method. In keeping with the security theories I need the plain text documents to be stored only in memory and never ever written to a physical drive. The tmpnam command appears to be what I need, but from what I can see it saves the file on the disk and not the RAM. Using C++ is there any ...

Is is possible to develop for windows, in C++, without Visual Studio?

I'm aspiring to work in real-time 3D graphics. I work almost exclusively in C++, with a healthy smattering of win32. Realistically, do I have any sane alternatives? ...

How to read in specific sizes and store data of an unknown type in c++?

I'm trying to read data in from a binary file and then store in a data structure for later use. The issue is I don't want to have to identify exactly what type it is when I'm just reading it in and storing it. I just want to store the information regarding what type of data it is and how much data of this certain type there is (informati...

Efficient way of extracting specific numerical attributes from XML

The application I work uses XML for save/restore purposes. Here's an example snippet: <?xml version="1.0" standalone="yes"?> <itemSet> <item handle="2" attribute1="30" attribute2="blah"></item> <item handle="5" attribute1="27" attribute2="blahblah"></item> </itemSet> I want to be able to efficiently pre-process the XML which I read i...

Importing a C# class library into Visual C++

Hi guys, I have a C# class library that contains methods that need to be used with an external application. Unfortunately this external application only supports external APIs in C/C++. Suppose I have a takeIntReturnDoubleArray method in this C# library that takes an integer and returns an array of doubles. All I need to do is have a...

cross compiling c++ to iphone arm

I've scanned over the (outdated) article that is the first hit on google about ARM cross-compiling. I've also seen the article about compiling OpenCV to the iPhone and the general cross compiling instructions there. My question is can I call the apparently already configured gcc/g++ in the iPhone developer package (which I already have i...

Why are some programs written in C++ windows-only and others are not?

That's something I've been wondering for a while now. Take Notepad++ for instace. Wikipedia tells me it was written in C++ and it's Windows-only. Now take PHP. Wikipedia tells me this is also written in C++, but that runs on other OS too. But I see more languages then just C++ for PHP... how is this done? Do they make some new code in...

C++: question about pointers and references

I have a function which takes a reference to an object- void move(Ball& ball); I have another function calling 'move()' which has a pointer to ball - void foo(Ball* ball){ //call move() } How is foo() supposed to pass ball to 'move()'? Should it be like - move(*ball); or move(ball); or move(&ball); ...

Why is this code losing handles on Windows 7 Beta?

I'm looking for some random crashes in an old c++ application. Using sysinternals process explorer, I noticed the app losing handles, and extracted the exact situation, where the program is losing handles to a very short piece of code. DWORD WINAPI MyTestThread( void* PThread) { _endthreadex(0); return 0; } int WINAPI WinMain( HINST...

How to use a BGL directed graph as an undirected one (for use in layout algorithm) ?

Hi I am working on a directed graph (actually a bidirectional one) with Boost.Graph. I'd like to use the layout algorithms that exist (either Kamada-Kawai or Fruchterman-Reingold) but they only accept undirected graphs as parameters. What is the simplest way to use these layout algorithms ? More generally, what's the right way to lure ...

WSACleanUp causes an exception

My app can switch between Serial and Socket connections, but neither can be open at the same time. So when I try to switch between a Socket to Serial, I delete the Socket connection. The socket based object uses a private class called UsesWinsock (a big shout out to Len Holgate here as it is basically his code (it is RAII actually but I...

Recommendations for logger in Linux application.

I'm building a C++ Linux application and I need to log its activity. What are the existing Linux facilities to create logs? What would you recommend? ...

Disable IE script debugging via IE control

Bleh; Knowing how to ask the question is always the hardest so I explain a little more. I'm using CAxWindow to create an IE window internally and passing in the URL via the string class argument: CAxWindow wnd; m_hwndWebBrowser = wnd.Create(m_hWnd, rect, m_URI, WS_CHILD|WS_DISABLED, 0); It's part of an automated utility for anyone to...

How to read input from a webcam in C++?

Hello, is it possible to read data from a generic webcam in C++ as you would from a stream object? Is there a common API or standard that works with all webcams? I'm talking about C++ in *nix environment. Thanks in advance. ...

Can I disable exceptions in STL?

Hello, I want to disable exceptions in my C++ aplication, compiled under MSVC. I hve switched the option Enable C++ exceptions to NO, but I get warnings telling me to use the option /Ehsc, which I dont want to. I do not have try/catch blocks in my code, but I use STL. I have found that using macro definition _HAS_EXCEPTIONS=0 should...

Where can I find a flexible logging library for Windows Mobile?

Can anyone suggest any open and free library for logging on Windows Mobile application written in C++? It would be nice if it supports logging to files, syslog (would be nice) and logging level. ...

Can I have nested try-catch blocks in C++?

Can I have nested try-catch blocks? For example: void f() { try { //Some code try { //Some code } catch(ExceptionA a) { //Some specific exception handling } //Some code } catch(...) { //Some exception handling } }/...

When to use forward declaration?

I am looking for the definition of when I am allowed to do forward declaration of a class in another class's header file: Am I allowed to do it for a base class, for a class held as a member, for a class passed to member function by reference, etc. Thank you. ...