c++

Direct Show (AMCap) - Platform SDK

Hi, I am trying to capture images from multiple web cams simultaneously and save them automatically with minimum delay using C++. I also want the program to be able to alter the parameters of the web cam when ever needed. I was hoping to build Direct show samples (AMCap) on Platform SDK, and then edit the code to suit my application. But...

Is there a simple way to get scaled unix timestamp in C++

I'm porting some PHP to C++. Some of our database code stores time values as unix time stamps *100 The php contains code that looks a bit like this. //PHP static function getTickTime() { return round(microtime(true)*100); } I need something like this: //C++ uint64_t getTickTime() { ptime Jan1st1970(date(1970, 1, 1)); ptime ...

streaming video to and from multiple sources

I wanted to get some ideas one how some of you would approach this problem. I've got a robot, that is running linux and uses a webcam (with a v4l2 driver) as one of its sensors. I've written a control panel with gtkmm. Both the server and client are written in C++. The server is the robot, client is the "control panel". The image analysi...

Why do C languages require parens around a simple condition in an if statement?

It sounds stupid, but over the years I haven't been able to come up with a use case that would require this. A quick google search didn't reveal anything worthwhile. From memory there was a use case mentioned by Bjarne Stroustrup but i can't find a reference to it. So why can't you have this in C languages: int val = 0; if val doSom...

[C++] Overlaying a struct onto a u_char pointer.

My professor has instructed me that we can lay a struct over (casting) the pointer in memory we are getting in order to more easily interpret the data. I asked about this in class today and this is what he said would work. This is not compiling complaining about how it can't cast it. What am I doing wrong? I am about to resort to parsi...

Unresolved external symbols in beginners CUDA program

I create a new Win32 Console App as an empty project I am running Windows 7 64bit with Visual Studio 2008 C++. I am trying to get the sample code from the bottom of this article to build: http://www.ddj.com/architect/207200659 I add CUDA Build Rule v2.3.0 to the project's custom build rules. It is the only thing with a checkbox in th...

openssl BF_cfb64_encrypt thread-safety

Is openssl's BF_cfb64_encrypt() thread safe? A sample code to use it to encrypt / decrypt a blob of data would be much appreciated. ...

Best Way To Marshal A Pointer of Array of Struct

I'm calling functions from C++ that returns a pointer to an array of struct and I'm having problems since I'm new to this operation/implementation. My C++ codes: // My C++ Structs typedef struct _MainData { double dCount; DataS1 *DS1; int iCount1; DataS2 *DS2; int iCount2; }MainData; typedef struct _DataS1 { ...

boost regex sub-string match

I want to return output "match" if the pattern "regular" is a sub-string of variable st. Is this possible? int main() { string st = "some regular expressions are Regxyzr"; boost::regex ex("[Rr]egular"); if (boost::regex_match(st, ex)) { cout << "match" << endl; } else { cout << "not match" << endl; } } ...

GetProfileInt() Not Returning Default Value

I'm using GetProfileInt to get key values from the registry. When the location exists, the code works, but when it does not, it returns 0 (and initializes the registry key to 0). Why doesn't this work? Code: SetRegistryKey(_T("MyKey")); int def = 0x1FFF; def = GetProfileInt(_T("Subkey"), _T("KeyWithVal"), def); ...

Easy way to add text above all methods in a solution in VS 2005?

A colleague was working on a Perl script to consume a C++ source file and add text above all of the methods in the file. He was looking to develop code using regular expressions from the ground up to detect the top line of the method: void MyClass::MyMethod(int somethingOrOther) Trying to do this from scratch is fraught with landmine...

How do I align QtWidget to right in the QtToolBar?

Hi, I have some QtWidget (QtLineEdit) and I would like to align it to the right in my QtToolBar. Is there any simple way to do it? Thanks. ...

Does MSVC automatically optimize computation on dual core architecture?

Does MSVC automatically optimize computation on dual core architecture? void Func() { Computation1(); Computation2(); } If given the 2 computation with no relations in a function, does the visual studio compiler automatically optimize the computation and allocate them to different cores? ...

C++ - Deleting a vector element that is referenced by a pointer

Hi all! Well, I don't know if it is possible, but the thing would be: struct stPiece { /* some stuff */ stPiece *mother; // pointer to the piece that created this one }; vector<stPiece> pieces; Is it possible to erase the piece referenced by 'mother' from pieces, having just that pointer as a reference? How? Would it mess with t...

Using C/C++ to efficiently de-serialize a string comprised of floats, tokens and blank lines

I have large strings that resemble the following... some_text_token 24.325973 -20.638823 -1.964366 0.753947 -1.290811 -3.547422 0.813014 -3.547227 0.472015 3.723311 -0.719116 3.676793 other_text_token 24.325973 20.638823 -1.964366 0.753947 -1.290811 -3.547422 -1.996611 -2.877422 0.813014 -3.547227 1.63236...

C++ Compiler Optimization for Fastest Possible Code in RAD Studio 2009

I would like to select the compiler optimizations to generate the fastest possible application. Which of the following settings should I set to true? Dead store elimination Eliminate duplicate expressions within basic blocks and functions Enable loop induction variable and strength reduction Enable pentium instruction scheduling Expan...

GCC dies trying to compile 64bit code on OSX 10.6

I have a brand-new off-the-cd OSX 10.6 installation. I'd now like to compile the following trivial C program as a 64bit binary: #include <stdio.h> int main() { printf("hello world"); return 0; } I invoke gcc as follows: gcc -m64 hello.c However, this fails with the following error: Undefined symbols: "___gxx_perso...

Test MPI_Barrier C++

Dear all, How can I be sure that MPI_Barrier act correctly? What's the method of test for that? Thank you ...

IcmpSendEcho and setting MTU size ?

Does anyone know if its possible to adjust the MTU while sending an ICMP echo packet (with IcmpSendEcho)? I'm trying to do this under Windows using the IcmpSendEcho() function. ...

Help with type traits

Suppose we have the following template class template<typename T> class Wrap { /* ... */ }; We can not change Wrap. It is important. Let there are classes derived from Wrap<T>. For example, class NewInt : public Wrap<int> { /* ... */ }; class MyClass : public Wrap<myclass> { /* ... */ }; class Foo : public Wrap<Bar> { /...