c++

How to get an accurate 1ms Timer Tick under WinXP

Hello, I try to call a function every 1 ms. The problem is, I like to do this with windows. So I tried the multimediatimer API. Multimediatimer API Source idTimer = timeSetEvent( 1, 0, TimerProc, 0, TIME_PERIODIC|TIME_CALLBACK_FUNCTION ); My result was that most of the time the 1 ms was ok, but someti...

Intrusive lists

I've not been able to find too much information about them online. What are they and when are they typically used? Thanks. ...

design question C++

I have just read an article about the Curiously Recurring Template Pattern. And you can use it simulate virtual function with templates. For example: template<class T> struct A { void func() { static_cast<T*>(this)->func(); } }; struct B : public A<B> { void func() { cout << "B" << endl; } };` However, if we have many subcla...

How do I keep a constant definition in a header file and not have it linked into every library?

Here's the scenario. We use Visual C++ 9. There's a C++ library intended to be used by many other libraries. Its interface is in a header: #pragma once //CommonLibraryHeader.h CSomeClass GetSomeClassFunction(); //is defined in some .cpp file const CSomeClass MagicValue( 100, 200 ); //some predefined value that the previous function ret...

Looking for comprehensive TR1 documentation online

I really like the online STL documentation provided by http://www.cplusplus.com/. Separately, I use some of the TR1 extensions via their Boost implementations. I would like to find TR1 documentation online which is as good as the standard STL documentation provided by cplusplus.com. I'm especially interested in smart pointers and th...

GUI with C++ ? or C# and Java the way to go?

Hi , I am nearly done with a course about using OOP in C++ and all the programs we wrote in that course were console applications . I also finished a university course in C programming so I think I have solid C programming basics and now is the time to make a big step towards GUI . I did a lot of googling and each time I read more page...

Comparing two Hexadecimal values in C++

Hi, I want to compare two hexadecimal(stored in long) below is my code long constant = 80040e14; if(constant == 80040e14) cout<<"Success"<<endl; else cout<<"Fail!!"<<endl; In this code flow control always returns to else part, can anyone please suggest how to proceed with the comparison. Thanks Santhosha K ...

VoIP Recoder Application

Hello. I need to develop VoIP Recoder Application using C++. Can anybody help with concerning works and open source libraries in given direction? Thanks. ...

How can I optimize a calculation-intensive C++ program with a known bottleneck?

I am developing some scientific software for my university. It is being written in C++ on Windows (VS2008). The algorithm must calculate some values for a large number of matrix pairs, that is, at the core resides a loop iterating over the matrices, collecting some data, e.g.: sumA = sumAsq = sumB = sumBsq = diffsum = diffsumsq = return...

two network interface at client side does not connect socket

i have two network interface installed on client system interface one has ip 192.168.3.1 and interface 2 has ip 192.168.5.1 ,i want to connect to remote system which has ip 192.168.5.7 but connection not establish.when i disable network interface 192.168.3.1 it will work fine. i am using the following code #include "windows.h" #include...

C++ passing struct or object by value

I have this: enum Units { Pounds, Kilos }; struct Configuration { const Units units; const char *name; inline Configuration(Units pUnits, char *pName) : units(pUnits) { name = strdup(pName); } inline ~Configuration() { free((void *)name); } }; I was passing one of these to a method like this: Config...

Best GUI compiler for C++

Possible Duplicate: Best C++ IDE or Editor for Windows There are couple of GUi compilers for C++ to work on Windows platform like VC++,Dev C++, etc. which one is the best used for testing some sample programs for a quick analysis of any small applications.I am presently using Dev C++ But is there a better compiler that anybody...

Why are cv-qualifiers in template parameters ignored?

I had some code that was failing to compile, which amounts to something like what's shown below. After some digging around, I came across paragraph 14.1 note 5, which states: The top-level cv-qualifiers on the template-parameter are ignored when determining its type. My code looks like this: #include <iostream> #include <t...

Problem Reading MBR with DeviceIoControl function

I get error while calling DeviceIoControl Function to read the MBR of a removable device. The error code is 5. That means access denied! I am using windows xp sp2. #include "stdafx.h" #include <windows.h> #include <winioctl.h> #include <stdio.h> BOOL GetMBR(PARTITION_INFORMATION *pdg) { HANDLE hDevice; // handle t...

how to work with container components using FFmpeg?

So are there any examples\materials on how to work with containers elements using ffmpeg? GFLV "tags" for example or Mpeg atoms? ...

C/C++ optimization: negate doubles fast

I need to negate very large number of doubles quickly. If bit_generator generates 0, then the sign must be changed. If bit_generator generates 1, then nothing happens. The loop is run many times over and bit_generator is extremely fast. On my platform case 2 is noticeably faster than case 1. Looks like my CPU doesn't like branching. Is ...

Setting up CEDET/EDE to work with Irrlicht

I have CEDET 1.0pre7 set up with emacs 23.1, and I want to use it to manage irrlicht programs. I am pretty new at writing non-academic C++ code, and makefiles. I got the following makefile to work for me: game.exe: game.o g++ game.o -o game.exe -L "D:/irrlicht/irrlicht-1.7.1/lib/Win32-gcc/" -l Irrlicht game.o: game.cpp g++ -c ga...

convert NTP time to Human-readable time

hello all. i have managed to make a NTP request and retrieve the server time from it's NTP response. i want to convert this number to a Human-readable time, writing in C++. can some one help me ? as example you can look at: http://www.4webhelp.net/us/timestamp.php?action=stamp&amp;stamp=771554255&amp;timezone=0 once you set the timestamp...

using stat to detect whether a file exists (slow?)

I'm using code like the following to check whether a file has been created before continuing, thing is the file is showing up in the file browser much before it is being detected by stat... is there a problem with doing this? //... do something struct stat buf; while(stat("myfile.txt", &buf)) sleep(1); //... do something else alt...

Why might HttpOpenRequest fail with error 122?

The following code fRequestHandle = HttpOpenRequestA( fConnectHandle, "POST", url.c_str(), NULL, NULL, NULL, INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE, 0); is returning NULL with GetLastError() returning 122. A search suggests th...