c++

Usefulness of signaling NaN?

I've recently read up quite a bit on IEEE 754 and the x87 architecture. I was thinking of using NaN as a "missing value" in some numeric calculation code I'm working on, and I was hoping that using signaling NaN would allow me to catch a floating point exception in the cases where I don't want to proceed with "missing values." Converse...

Does using large libraries inherently make slower code?

I have a psychological tic which makes me reluctant to use large libraries (like GLib or Boost) in lower-level languages like C and C++. In my mind, I think: Well, this library has thousands of man hours put into it, and it's been created by people who know a lot more about the language than I ever will. Their authors and fan...

find string of N 1-bits in a bit-array

As the title sais I want to find a successive run of n one-bits in a bit-array of variable size (M). The usual use-case is N <= 8 and M <= 128 I do this operation a lot in an innerloop on an embedded device. Writing a trivial implementation is easy but not fast enough for my taste (e.g. brute force search until a solution is found). I...

How might I obtain an IShellFolder from the active IShellView?

I'm trying to enhance a CFileDialog, and we're using the older version of it (the non-vista one that doesn't use IFileDialog). The older one does allow me to obtain an IShellBrowser, as well as (from that) the active IShellView. What I cannot seem to come up with is a way to get "What IShellFolder does that IShellView refer to?" Equal...

How can I build a C/C++ program using `static linking` & `Dynamic linking` with gcc & Visual studio?

A library can be used in an application in two ways: Statically-linked Dynamically-linked But how to do that using both Visual Studio (windows) & GCC? I know libraries are distributed only in these 4 ways: Source header-only libraries *.lib files for windows. *.a for linux *.dll (windows) & *.so (linux). Source distribution is j...

How to properly use extern in a namespace?

I'm working on getting rLog to build as a DLL under windows, and I was getting undefined symbol errors relating to some global symbols in the rlog namespace. Specifically these in RLogChannel.cpp: namespace rlog { ... RLogChannel *_RLDebugChannel = GetGlobalChannel( "debug", Log_Debug ); RLogChannel *_RLInfoChannel = GetGlob...

Fast asymmetric cypher for C++ application

Hello. I'm looking for a fast asymmetric cypher algorithm to be used in C++ program. Our application accesses read-only data stored in archive (custom format, somewhat similar to tar), and I would like to prevent any modifications of that archive by asymmetrically encrypting archive index (I'm aware that this isn't a perfect solution an...

Anyone benchmarked virtual machine performance for build servers?

We have been trying to use virtual machines for build servers. Our build servers are all running WinXP32 and we are hosting them on VMWare Server 2.0 running on Ubuntu 9.10. We build a mix of C, C++, python packages, and other various deployment tasks (installers, 7z files, archives, etc). The management using VMWare hosted build serv...

sending mail with attachment in c++? (or How do I construct a MIME encoded email message that I can send to SMTP?)

is it possible to do it without any third-party lib. i can send mail to gmail with a simple socket functions. i can send files one computer to another too. But i need to send with attachment to any mail account... can it be done with smtp? (i searched in here but the answers, that i looked, are not in c++ or not on windows or not ope...

Working program gets an Illegal instruction fault on 'clean machine' ?

I have a program that works correctly on my development machine but produces an Illegal instruction fault when tested on a 'clean machine' where only the necessary files have been copied. The program consists of my shared library, built from C++ sources and a C wrapper sample program that demonstrates the libraries usage. On the develop...

deque vs. queue in C++

Queue and Stack are a structures widely mentioned. However, in C++, for queue you can do it in two ways: #include <queue> #include <deque> but for stack you can only do it like this #include <stack> My question is, what's the difference between queue and deque, why two structures proposed? For stack, any other structure could be i...

Qt: Defining a custom event type

I have created a custom event in my Qt application by subclassing QEvent. class MyEvent : public QEvent { public: MyEvent() : QEvent((QEvent::Type)2000)) {} ~MyEvent(){} } In order to check for this event, I use the following code in an event() method: if (event->type() == (QEvent::Type)2000) { ... } I would like to b...

QWebElement manipulation of a QWebPage in a separate thread

Hi, I have a QWebPage created in the main thread (you can't create it anywhere else). I would like to manipulate this page using the QWebElement API introduced in Qt 4.6, but in a separate thread. So that thread would acquire a reference to the page and perform the necessary tree walking and attribute changes I need. As the Threads and...

C++ change Opera proxy settings

I'm writing an http proxy program in C++ and I need it to automatically configure the default browser proxy settings to use my proxy. With IE i can just modify the registry, Chrome has a command line parameters that can be used, firefox has the prefs file, but I can't figure out how to do it for Opera. It needs to be compatible with all ...

set map implementation in C++

Hi I find that both set and map are implemented as a tree. set is a binary search tree, map is a self-balancing binary search tree, such as red-black tree? I am confused about the difference about the implementation. The difference I can image are as follow 1) element in set has only one value(key), element in map has two values. 2) se...

Array boundaries and indexes

I had an earlier post link textwhere someone said I had my pointer initialized to the wrong element which I don't quite see why, other than they are right and it works with their correction. So here is the basic problem: If I declare an array from 0 to 30 with #define ENDPOINT 15 int record[2 * ENDPOINT + 1]; // and want a pointer to ...

Qt build that can link statically out of the box?

I have used Qt to build a small application. It turns out that I need to reconfigure and Qt from scratch in order to be able to link statically. I've done it before, and I remember that it was a very long process. So does anyone know a Qt SDK installer that provides the ability for static linking out of the box? ...

Understanding Factories and should I use them?

I have never used Factories before for the simple reason, I don't understand when I need them. I have been working on a little game in my spare time, and I decided to implement FMOD for the sound. I looked at a wrapper designed for OpenAL(different sound setup) and it looked something like... SoundObject* SoundObjectManager* SoundObject...

C++ "dynamic" arrays

I've got some problems/misunderstandings with arrays in C++. int myArray[30]; myArray[1]=2; myArray[2]=4; This is spitting out a lot of compiler errors. I don't think it is necessary to include them here as this is an easy question for everybody with experience in C(++) I guess Why doesn't this work? Is there a way to create a "dyna...

Choosing between static libs and dynamic libs/plugins?

I have been throwing stuff together in a small test game over the past 6 months or so, and right now everything is in the one project. I would like to learn more about creating an "engine" for reusability and I am trying to figure out the best way to do this. Static Libs are obviously a tiny bit faster, as they are compiled in rather th...