c++

CComVariant vs. _variant_t, CComBSTR vs. _bstr_t

I am using ATL (VS2008, so ATL9 IIRC) to create COM objects and have been using the CComVariant class (defined in atlcomcli.h) to manage VARIANT types. However, there is also another VARIANT wrapper called _variant_t. Is there any difference between CComVariant and _variant_t and which one should I be using? Similarly, there are two B...

How could I simulate _set_abort_behavior in VC++7 and earlier?

In Visual C++ when terminate() is called the default behavior is to call abort() which by default shows a message box and then - after OK button on the message box is pressed - terminates the application. The "shows message box" part is not very good for programs that must work without human interaction since the program just hangs until...

C++: How to build Strings / char*

Hi, I'm new to C++. I want to make a char*. But I don't know how. In Java is it just this: int player = 0; int cpu = 0; String s = "You: " + player + " CPU: " + cpu; How can I do this? I need a char*. Where I'm focusing on is to paste the integer after the string. Edit: I want to use a method that takes an argument char *, so if...

ReadWrite lock using Boost.Threads (how to convert this simple class)

I am porting some code from windows to Linux (Ubuntu 9.10). I have a simple class (please see below), which uses windows functions to implement simple mutex locking. I want to use Boost.Threads to reimplement this, but that library is new to me. Can someone point out the changes I need to make to the class below, in order tomuse Boost.T...

CallBack function from c# to c++

Hi All, I have a C# exe and some vc++ dll's . I am creating a callBackFunction in C# whichh takes structure as its Parameters. My c++ dll will fill this structure and return it back.But 95% of the time My Exe crashes. My dll is multi threaded and my C# has backgroundWorker in it. I have put try catch block to check if any exceptions are...

C++: Newbie: Is this code valid, or is it the compiler?

Hi, int cpu = 0; int player = 0; char * getPoints() { using namespace std; string str = "You: "; str += player; str += " CPU: "; str += cpu; char c [100]; strcpy(c, str.c_str()); return c; } This code doens't compile. Is the code wrong or is there something wrong with my compiler? I'm using Microsoft V...

How to test if template parameter is a pair associative container ?

Let's imagine I want to make a templated function that returns the first element of any stl container. The general way would be : template<typename Container> Container::value_type first(Container c){ return *(c.begin()); } This works for vectors, lists, deques, sets and so on. However, for pair associative containers (std::map),...

Are there Visual C++ runtime implementations for other platforms?

Does Visual C++ runtime imply Windows platform? I mean if I write a program that only directly uses functions specific to VC++ runtime and doesn't directly call Windows API functions can it be recompiled and run on any OS except Windows? I don't mean on Windows system emulator, I mean a ready implementation of VC++ runtime for some other...

Can I have platform specific sections in my vsprops (Property Sheet) file?

I'm creating a vsprops file to contain include and lib paths that are common to all projects in my solution. However, I have platform specific paths for the lib paths which can be Win32/x64. Is it possible to put these settings in one vsprops file? Or do I have to create a different vsprops file for each platform and then spend time wit...

Complement to valgrind?

I have been working for the last few weeks trying to track down a really difficult bug that crashes my application. First, the application was crashing on the assign of a std::string, then during the free of a local variable. After careful inspection of the code, there was no reason for it to crash at these locations; however, it alway...

What is the mistake in my code. please help

Hi..i am new to QT the sample code mentioned below is not compiling ..please tell me the reason. #include "QprogressBar.h" #include <QtGui> #include <QApplication> #include<qprogressbar.h> #include <qobject.h> lass myTimer: public QTimer { public: myTimer(QWidget *parent=0):QTimer(parent) {} public slots: void recivetime(); };...

Array indexing starting at a number not 0 in c

Is it possible to start an array at an index not zero...I.E. you have an array a[35], of 35 elements, now I want to index at say starting 100, so the numbers would be a[100], a[101], ... a[134], is that possible? I'm attempting to generate a "memory map" for a board and I'll have one array called SRAM[10000] and another called BRAM[5000...

C++: How to add a library in Netbeans (DarkGDK + DirectX SDK)

Hi, I'm trying to learn how to make games with DarkGDK. But I have to write in Visual Studio. I don't like Visual Studio. Its suggestions (Ctrl-Space for Completion) are bad (is my opinion) and the compiler is broken (See my previous questions). So I want to migrate to Netbeans, whit MSys and MinGW. But I'm not able to use the DarkGDK...

How to select the version of the VC 2008 DLLs the application should be linked to?

I'm using Visual Studio 2008 SP1 for C++. When compiling, Visual Studio needs to choose against which version of the CRT and MFC DLLs the application should be linked, version 9.0.21022.8 (= RTM), 9.0.30729.17 (= SP1) or 9.0.30729.4148 (= SP1 with security update). I'd like to know how you can choose which of both versions will be linked...

Directdraw: Rotate video stream

Problem http://stackoverflow.com/questions/2318390/windows-mobile-directdraw-rotate-video-stream The video preview is working, all I need now is a way to rotate the image. I think the only way to handle this is to write a custom filter based on CTransformFilter that will rotate the camera image for you. If you can help me to solve this...

The best learning route into Object Oriented Programming from C?

What is the best route to go for learning OOP if one has done some programming in C. My intention was first to take the natural leap and "increment with one" and go for Stroustrup. But since I got my hands on the little old Bertrand Meyers OOSC2 and I qoute from the appendix page 1135 "..according to Donald Knuth, it would make Edsger D...

Strange Serial MisComunication

Ok, so I have 3 devices. an AVR Butterfly microcontroller, set up with USART A Bifferboard, running Debian, using a custom made program for serial. A Desktop machine running Br@y's. So I'm trying to make the Bifferboard send serial to the AVR, But the AVR never recieves the signal, (We've checked the wires) But if i connect the AVR to ...

How to hide menu? lpszMenuName

I managed to make the menu with this piece of code and using Visual Studio 2008: WNDCLASS wc; ... wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); ... if(!RegisterClass(&wc)) ... But how i can hide the menu by just pressing a button of my choice? There is ShowWindow() function, but it doesnt work on menus... so what function i use to...

Beginner extending C with Python (specifically Numpy)

I am working on a real time audio processing dynamically linked library where I have a 2 dimensional C array of floating point data which represents the audio buffer. One dimension is time (samples) and the other is channel. I would like to pass this to a python script as a numpy array for the DSP processing and then I would like to pass...

Need help with an Algorithm for non-contiguous Array. Index grouping

I'm need some help writing an algorithm in C/C++ (Although an language example would suffice). The purpose is a container/array, which allows insertion at any index. However if inserting an element in an index that is not close to an existing index i.e. would cause an large empty space of buckets. Then the array minimising the empty buc...