c++

Mapping ISpMMSysAudio::SetLineId and mixerLineId

I want to set the lineId for SAPI by calling ISpMMSysAudio::SetLineId. I find out the line which I wish to set from the mixer handle I have. However the line id I get from the mixer is not what SAPI assumes. It results in SAPI listening to the wrong input line for mic thus getting no input. I'm getting the mux control for "DST_WAVEIN" f...

Is there any way to embed egrep and wget in my application ?

hello all i need in my application the feathers that the good old egrep and wget give me , but i can't execute them as separate process i need them as embedded functions in my application is there any way to do that ? cross platform and c++ ...

Assigning value to allocated char array fails...

I simply allocate some memory for a character and wanna do then some pointer arithmetic. In this case I wanna write '\x0a' to byte 32 as follows: #define HDR_SIZE 32 int size = 52; unsigned char *readXPacket = (unsigned char *) malloc (size * sizeof (unsigned char)); *readXPacket + HDR_SIZE = '\x0a'; When I try doing that I get t...

Catching exceptions polymorphically

Here is main(): int main() { B b(1,"two","three"); try { f1(b); } catch(B& b_ref) { cout<<"Caught B&"<<endl; b_ref.print(); } catch(A& a_ref) { cout<<"Caught A&"<<endl; a_ref.print(); } system("pause"); return 0; } Here is f1(): void f1(A& subjec...

Programs compiles in g++ but exits with linker errors in gcc

I'm trying out the solution to a question about specialized template classes. This code with a compiles fine in g++, but throws up linker errors when compiled with gcc. What's the cause of these errors ? $ g++ traits2.cpp $ gcc traits2.cpp /tmp/ccI7CNCY.o: In function `__static_initialization_and_destruction_0(int, int)': traits2.cpp...

Elegant way to add metainformation to char array

I wanna pack some information plus some metadata in a byte array. In the following I have 3 bytes of information which have a certain offset plus 4 bytes of metadata added at the beginning of the packet in the end. Solution 1 I came up is pretty obvious to do that but requires a second tmp variable which I do not really like. int size =...

C++ mysql and boost asio header conflict

There seems to be a conflict with the windows headers between the mysql c-api and boost::asio. If I include mysql first I get: boost/asio/detail/socket_types.hpp(27) : fatal error C1189: #error : WinSock.h has already been included #if defined(BOOST_WINDOWS) || defined(__CYGWIN__) # if defined(_WINSOCKAPI_) && !defined(_WINSOCK2A...

Building a vector from components contained in another vector type

I have a code that looks something like this: struct First { int f1; int f2; }; struct Second { First s1; int s2; }; std::vector < Second > secondVec; Second sec; sec.s1 = First(); secondVec.push_back(sec); secondVec.push_back(sec); std::vector < First > firstVec; firstVec.reserve(secondVec.size()); for (std::vect...

Aspect ratios - how to go about them? (D3D viewport setup)

Allright - seems my question was as cloudy as my head. Lets try again. I have 3 properties while configuring viewports for a D3D device: - The resolution the device is running in (full-screen). - The physical aspect ratio of the monitor (as fraction and float:1, so for ex. 4:3 & 1.33). - The aspect ratio of the source resolution (source...

When exactly is the postfix increment operator evaluated in a complex expression?

Say I have an expression like this short v = ( ( p[ i++ ] & 0xFF ) << 4 | ( p[ i ] & 0xF0000000 ) >> 28; with p being a pointer to a dynamically allocated array of 32 bit integers. When exactly will i be incremented? I noticed that the above code delivers a different value for v than the following code: short v = ( p[ i++ ] & 0xFF) ...

How does FastCGI work on a web server (eg. Apache 2.2+)?

Hi, I had a look at the sources of FastCGI (fcgi-2.4.0) and actually there's no sign of fork. If I'm correct the web server spwans a process for FastCGI module (compiled in it or loaded as a SO/DLL) and handles control of the main socket (the port TCP:80 usually) over to it. On *nix the FastCGI module "locks" that socket using a file w...

ATL Security update broke compatibility for DLLs depending on the older version

The recent ATL security update updated the C++ runtimes to version 8.0.50727.4053. Unfortunately, this update broke one of our DLLs that dynamically links to the runtime, as we only have 8.0.50727.762 available to us on the target machine (we don't even use ATL). Is there a way we can get Visual Studio to dynamically link to the older ...

What should I do to develop a well structed C++ program?

Right now, I want to develop a C++ program. And the UI design is the difficult issue. my question is: 1. is there any good practice for developing a well structed c++ program ? 2. is there any good practice for developing UI in c++? 3. I usually heard of Activex in C++, can it use to encapsulate a UI, and is good for maintain after sof...

MVC with Qt widget that uses a QAbstractTableModel subclass

Hi, I'm doing some refactoring. I'm implementing a Model-View-Controller pattern. The view is a Qt widget. Originally, the Qt widget created a new instance of a QAbstractTableModel subclass on the heap. Lets call it FooTableModel. e.g Widget::Widget(QWidget* parent) : QWidget(parent) m_model(new FooTableModel(this)) { Should I ...

some questions about MFC development?

How do you develop UI in MFC? do you use any free libray, or usually develop from scratch? There are always so many DLL files in a C++ developed software, what are them used for ? What's the difference between MFC ActiveX Control and MFC DLL ? ...

QGraphicsView and QGraphicsItem: don´t scale item when scaling the view rect

Hi, I am using Qt´s QGraphicsView- and QGraphicsItem-subclasses. is there a way to not scale the graphical representation of the item in the view when the view rectangle is changed, e.g. when zooming in. The default behaviour is that my items scale in relation to my view rectangle. I would like to visualize 2d points which should be rep...

C++ compile time program wide unique numbers

I've come up with a solution to a problem but I'm not sure if it'll always work or just on my compiler. First, the problem: I've noticed in a number of situations it's desirable to have a template class that gets reinstantiated each time it's used even when given the same types (say your template class has static members that are initial...

boost::asio, asynchronous read problem

For some reason this results in an access violation, however not having any detailed documentation/help on this I'm not sure where I'm doing it wrong, since going by what ive seen on the boost site this should be correct, and print the contents of each asio::write call from the client to a new line... the client seems to work fine, altho...

C++ Timers in Unix

We have an API that handles event timers. This API says that it uses OS callbacks to handle timed events (using select(), apparently). The api claims this order of execution as well: readable events writable events timer events This works by creating a point to a Timer object, but passing the create function a function callback: Some...

What is this piece of c++ code doing?

I don't know how and why this piece of code works: // postorder dfs Iterator< Index<String<char> >, TopDown<ParentLink<Postorder> > >::Type myIterator(myIndex); while (goDown(myIterator)); for (; !atEnd(myIterator); goNext(myIterator)) // do something with myIterator ( Traverse Through (Suffix)-tree ) It's an example from seqan ...