c++

Get machine properties

Hi, I would like to write a program that will identify a machine( for licensing purposes), I tought about getting the following information and to compile an xml file with this data: MAC address. CPU data (serial, manufacture, etc) MotherBoard Identification. (serial, manufacture, etc) can someone refer me to a lib that provide such...

What is __gxx_personality_v0 for?

This is a second-hand question from an OS development site, but it made me curious since I couldn't find a decent explanation anywhere. When compiling and linking a free-standing C++ program using gcc, sometimes a linker error like this occurs: out/kernel.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' This is appar...

Writing Multithreaded Exception-Safe Code

What are the tensions between multithreading and exception-safety in C++? Are there good guidelines to follow? Does a thread terminate because of an uncaught exception? ...

VisualWorks Smalltalk-like IDE for C++ (Linux)

Sup bros, Is there anything out there for C++ which displays the class hierarchies as a tree on the left panel? I've been using VisualWorks Smalltalk for a while, and the way that classes are displayed, and methods broken out, makes it very easy to build a mental picture of what the class does. Sadly, I can't find anything similar for...

Detecting (unknown) hardware in .NET

I need some pointers on how to detect unknown hardware using .NET and C++/C#. I'm looking for the technique to use under NET to do this. What I basically want is to identify the PCIID/USBID and so on for all the hardware in the machine. Of course I also need this for the hardware that doesn't yet has a driver installed. I believe this ...

Is Pointer Variable also Assigned a Memory Address?

In C++: On stack, a simple variable is assigned a memory address so that we can use pointer to contain this memory to point to it; then is a pointer also assigned a memory address? if yes, we can have pointer of pointers now? Thanks! ...

There is a function to use pattern matching (using regular expressions) in C++?

There is a simple C++ method to use pattern matching on strings? The code should sound like this: if (regexpcmp("l?nole*[0-9]", "linoleum1")) { //we have a match! } else { //no match } ...

C++ design question - Network packets and serialization

I have, for my game, a Packet class, which represents network packet and consists basically of an array of data, and some pure virtual functions I would then like to have classes deriving from Packet, for example: StatePacket, PauseRequestPacket, etc. Each one of these sub-classes would implement the virtual functions, Handle(), which w...

Extracting MAC addresses from UUIDs

A program that I work on assumes that the UUID generated by the Windows RPC API call UuidCreateSequential() contains the MAC address of the primary ethernet adapter. Is this assumption correct or should I use a different method to get the MAC address? ...

Rationale behind return 0 as default value in C/C++

Hi, Is there a reason why zero is used as a "default" function return value? I noticed that several functions from the stdlib and almost everywhere else, when not returning a proper number (e.g pow(), strcpy()) or an error (negative numbers), simply return zero. I just became curious after seeing several tests performed with negated log...

Static Variables, Separate Compilation

Hi, I wrote a program out, which was all in one file, and the methods were forward declared in a header. The program initially worked perfectly when it was in one file. But when I separated the program, I kept getting random occurrences for the destructor of one of the classes which was declared in the header file. I have a static v...

Safe To Modify std::pair<U, V>::first in vector of pairs?

I'm currently working on a DNA database class and I currently associate each row in the database with both a match score (based on edit distance) and the actual DNA sequence itself, is it safe to modify first this way within an iteration loop? typedef std::pair<int, DnaDatabaseRow> DnaPairT; typedef std::vector<DnaPairT> DnaDat...

Which On-Screen Keyboard for Touch Screen Application?

I'm developing an application in C++ that's partially driven by touch-screen on Windows XP Embedded. Some text entry will be necessary for the user. So far we've been using the standard Windows On-Screen Keyboard (osk.exe), but there are two main problems: It's rather small on a higher resolution screen which will probably make it ha...

C language: long long implementaion in 32 bit machine

As per c99 standard, size of "long long" should be minimum 64 bits. How this is implemented in a 32 bit machine(eg. addition or multiplication of 2 "long long"s). What is the equivalent of long long in C++. ...

C++ Constructor coding errors

I just stumbled across this bug in some legacy code: class MyAPIHandler { private: int handle; public: void MyApiHandler() // default constructor { handle = 42; }; }; It compiles fine, with no warnings - but the behaviour wasn't what I intended, because the constructor name is misspelt. This by itself wo...

How to resolve this VC++ 6.0 linker error?

This is a Windows Console application (actually a service) that a previous guy built 4 years ago and is installed and running. I now need to make some changes but can't even build the current version! Here is the build output: --------------------Configuration: MyApp - Win32 Debug-------------------- Compiling resources... Compiling... ...

Using C++ DLLs with different compiler versions

This question is related to "How to make consistent dll binaries across VS versions ?" We have applications and DLLs built with VC6 and a new application built with VC9. The VC9-app has to use DLLs compiled with VC6, most of which are written in C and one in C++. The C++ lib is problematic due to name decoration/mangling issues. Compil...

When is anonymous namespace data initialized?

I have been using anonymous namespaces to store local data and functions and wanted to know when the data is initialized? Is it when the application starts in the same way as static data or is it compiler dependent? For example: // foo.cpp #include "foo.h" namespace { const int SOME_VALUE = 42; } void foo::SomeFunc(int n) { if...

How to get serial number from hard disks?

Is there an easy way to get the serial number of all the hard disks in a PC using the Win32 API? ...

Does C++ allow default return types for functions?

In C the following horror is valid: myFunc() { return 42; // return type defaults to int. } But, what about in C++? I can't find a reference to it either way... My compiler (Codegear C++Builder 2007) currently accepts it without warning, but I've had comments that this is an error in C++. ...