c++

How do I dynamically bind a socket to only one network interface?

Currently I do the following to listen on any available port on all interfaces: // hints struct for the getaddrinfo call struct addrinfo hints, *res; memset(&hints, 0, sizeof hints); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; // Fill in addrinfo with getaddrinfo if (getaddrinfo(NULL, "0", &...

Speed of C program execution

Hi all, I got one problem at my exam for subject Principal of Programming Language. I thought for long time but i still did not understand the problem Problem: Below is a program C, that is executed in MSVC++ 6.0 environment on a PC with configuration ~ CPU Intel 1.8GHz, Ram 512MB #define M 10000 #define N 5000 int a[M][N]; void main(...

Unique Machine ID for a Windows CE Device

I need to generate unique machine ID for a CE 6.0 device. On Windows OS, I was using the WMI to obtain some hardware identifiers from which I constructed this ID. Apparently, WMI is not supported on Win CE so I am looking for alternatives. At the moment I am playing with OS image that I have constructed in Platform Builder and testing m...

VIM: is there an easy way to manage Visual Studio solutions / makefile projects from Vim?

Hello, I tried using Visual Studio instead of VIM(+plugins), but to be honest - the only advantage of VS over VIM is it's ability to automatically manage my project. I know of existence of ViEmu for VS, but I would like to do the opposite - is there any way to manage projects from within VIM? I tried both c.vim plugin and Project pl...

How can I calculate the free address space on Windows?

How can I calculate the amount of free virtual address space my process have on Windows? My application need to limit the amount of address space used. So I need to estimate how many memory I have consumed and how many virtual memory is left. If I have just a few hundred megabytes of address space left, my process begins to use a custo...

Live RX and TX rates in linux

I'm looking for a way to programatically (whether calling a library, or a standalone program) monitor live ip traffic in linux. I don't want totals, i want the current bandwidth that is being used. I'm looking for a tool similar (but non-graphical) to OS X's istat menu's network traffic monitor. I'm fairly certain something like this ex...

Smart pointers. When, where and how?

First off, since there are different kinds of smart pointers, I'd like to focus this question on two of them: reference counted intrusive and non-intrusive smart pointers. The question is asked individualy for each pointer type. I am not really sure how to formulate my question, so here's what I'm not asking: I am not asking why, or whe...

Where to find documentation about multitouch API for Windows 7?

Where can I get the documentation about multitouch API for Windows 7? ...

CSV parser in C++

All I need is a good CSV file parser for C++. At this point it can really just be a comma-delimited parser (ie don't worry about escaping new lines and commas). The main need is a line-by-line parser that will return a vector for the next line each time the method is called. I found this article which looks quite promising: http://www...

Capturing a time in milliseconds

The following piece of code is used to print the time in the logs: #define PRINTTIME() struct tm * tmptime; time_t tmpGetTime; time(&tmpGetTime); tmptime = localtime(&tmpGetTime); cout << tmptime->tm_mday << "/" <<tmptime->tm_mon+1 << "/" << 1900+tmptime->tm_year << " " << tmptime->tm_hour << ":" << tmptime->tm_min << ":" << tmptim...

Performances issues when launching an application on a parallel machine

Hi, I've a really strange problem: I've an application that launches some workers on parallel: for (it = jobList.begin(); it != jobList.end(); it++) { DWORD threadId; Job job = *it; Worker *worker = new Worker(job); workers[i] = worker; threads[i++] = CreateThread((LPSECURITY_ATTRIBUTES)NULL, (DWORD)0, &launchThread...

Where to find API documentation for NVIDIA 3D Vision?

I'd like to start coding for NVIDIA 3D Vision and wonder where can I find the documentation for it? ...

Is it possible to add a static variable to a C++ struct?

I am getting the following error when trying to add a static variable to my struct: Undefined Symbole s2::aa in module file_name.cpp s2 is the name of the structure and aa is the static variable. The compiler I am using is Turbo C++ 3.0. How do I fix this error? ...

Am I going to be OK for threading with STL given these conditions?

I have a collection of the form: map<key, list<object> > I only ever insert at the back of the list and sometimes I read from the entire map (but I never write to the map, except at initialization). As I understand it, none of the STL containers are thread safe, but I can only really have a maximum of one thread per key. Am I miss...

Linking VS2005 static library with gcc in Windows

Is it possible to link a static library built with VS2005 into an application that is to be built with gcc (in Cygwin)? ...

Derived template-class access to base-class member-data

This question is a furtherance of the one asked in this thread. Using the following class definitions: template <class T> class Foo { public: Foo (const foo_arg_t foo_arg) : _foo_arg(foo_arg) { /* do something for foo */ } T Foo_T; // either a TypeA or a TypeB - TBD foo_arg_t _foo_arg; }; template <...

Keeping objects in sync across a network?

In my application, I have two DLLs. One is written in C# and the other in C++. They communicate with each other across a network. Each has a list of object instances that are expected to be in sync with each other at all times. What network libraries are available for doing this? ...

Detect if C++ binary is optimized

Is there a flag or other reliable method to detect if a compiled C++ binary was compiled with optimizations? I'm okay with compiler-specific solutions. Edit: This is for a build deployment system, which could accidentally deploy binaries that were not built properly. A water-tight solution is unlikely, but it will save some pain (an...

Can you put a library inside a namespace?

I am working with OpenCV and I would like to put the entire library inside it's own namespace. I've looked around quite a bit but haven't found an answer... Can you do this without modifying the library source code? If then how? ...

Set binary data using setblob in mysql connector/c++ causes crash

I tried to use setBlob() as follows: class DataBuf : public streambuf { public: DataBuf(char * d, size_t s) { setg(d, d, d + s); } }; char b[20]; DataBuf buffer((char*)b, 20); istream stream( PreparedStatement* s = con->PrepareStatement("insert into mytable (mybin) values (?)"); s->setBlob(1, int rows = s->executeUpdate...