c++

pthread_key_t and pthread_once_t?

Starting with pthreads, I cannot understand what is the business with pthread_key_t and pthread_once_t? Would someone explain in simple terms with examples, if possible? thanks ...

Why use prefixes on member variables in C++ classes

A lot of C++ code uses syntactical conventions for marking up member variables. Common examples include m_*memberName* for public members (where public members are used at all) _*memberName* for private members or all members Others try to enforce using this->member whenever a member variable is used. In my experience, most larger c...

How does Visual Build (kinook) build c++ projects?

The bld file has the sln file specified, but what does it call to build it? MSDev? MSBuild? other? I want to add some command line params, but I am not sure which executable it calls for unmanaged C++ solutions. ...

Boost::Asio read/write operations

What is the difference between calling boost::asio::ip::tcp::socket's read_some/write_some member functions and calling the boost::asio::read/boost::asio::write free functions? More specifically: Is there any benefit to using one over the other? Why are both included in the library? ...

How does one include TR1?

Different compilers seem to have different ideas about TR1. G++ only seems to accept includes of the type: #include <tr1/unordered_map> #include <tr1/memory> ... While Microsofts compiler only accept: #include <unordered_map> #include <memory> ... As for as I understand TR1, the Microsoft way is the correct one. Is there a way to ...

What configuration file format allows the inclusions of otherfiles and the inheritance of settings?

I'm writing a Multiplayer C++ based game. I need a flexible file format to store information about the game charactors. The game charactors will often not share the same attributes, or use a basew For example: A format that would allow me to do something like this: #include "standardsettings.config" //include other files which thi...

How to call the RJ45 as a serial port for interfacing?

Hi, I'm currently working on a serial interfacing project based upon connecting to the rs232 port. However, seeing as a decent number of laptops and/or PC's seem like they might have their rs232 ports disappear within the next 5 years, I was considering using the RJ45 modular port for my project (EIA/TIA 568). However, I'm not quite sur...

Visual Studio 2008, Runtime Libraries usage advice

Hello all, I would like some information on the runtime libraries for Visual Studio 2008. Most specifically when should I consider the DLL versions and when should I consider the Static versions. The Visual Studio documentation delineates the technical differences in terms of DLL dependencies and linked libraries. But I'm left wonderin...

How to pass bool from c# through c++ com interface in idl

I know I'm missing something simple, I have next to no experience with these com things. I would like to do this within an interface in an idl [id(5), helpstring("Returns true if the object is in a valid state.")] HRESULT IsValid([out, retval] boolean bValid); However this gives : [out] paramter is not a pointer. Ok, I understand th...

How do I force a program to appear to run out of memory?

I have a C/C++ program that might be hanging when it runs out of memory. We discovered this by running many copies at the same time. I want to debug the program without completely destroying performance on the development machine. Is there a way to limit the memory available so that a new or malloc will return a NULL pointer after, sa...

OO Programming Question: Global Object

Hi I have probably a quite simple problem but I did not find a proper design decision yet. Basically, I have 4 different classes and each of those classes has more than 10 methods. Each of those classes should make use of the same TCP Socket; this object keeps a socket open to the server throughout program execution. My idea was to hav...

Using SQL statements to query in-memory objects

Suppose I have a collection of C++ objects in memory and would like to query them using an SQL statement. I’m willing to implement some type of interface to expose the objects’ properties like columns of a database row. Is there a library available to accomplish this? In essence, I’m trying to accomplish something like LINQ without usi...

How do I prevent my 'unused' global variables being compiled out?

Hi, I'm using static initialisation to ease the process of registering some classes with a factory in C++. Unfortunately, I think the compiler is optimising out the 'unused' objects which are meant to do the useful work in their constructors. Is there any way to tell the compiler not to optimise out a global variable? class SomeClass {...

Manual invocation of constructor?

Suppose I am allocating an arbitrary block of memory. Part of this block is atomic data (ints, bytes, etc.) and some of this block of data I want to be occupied by objects. Can I turn any arbitrary piece of memory into an object through a constructor call, such as data->MyObject () and subsequently destroying the object via data->~MyOb...

Simultaneous C++ development on Linux and Windows

We have a handful of developers working on a non-commercial (read: just for fun) cross-platform C++ project. We've already identified all the cross-platform libraries we'll need. However, some of our developers prefer to use Microsoft Visual C++ 2008, others prefer to code in Emacs on GNU/Linux. We're wondering if it is possible for all...

Source code for hashmap implementation?

I’d like to study the source code for a fast and memory efficient hashmap implementation. Any suggestions where I can find one online? ...

Serialize a structure in csharp to C++ and vice versa

Hi, Is there an easy way to serialize a csharp structure and then deserialize it from c++. I know that we can serialize csharp structure to xml data, but I would have to implement xml deserializer in c++. what kind of serializer in csharp would be the easiest one to deserialize from c++? I wanted two applications (one C++ and another csh...

reinterpret casting to and from unsigned char* and char*

I'm wondering if it is necessary to reinterpret_cast in the function below. ITER_T might be a char*, unsigned char*, std::vector<unsigned char> iterator, or something else like that. It doesn't seem to hurt so far, but does the casting ever affect how the bytes are copied at all? template<class ITER_T> char *copy_binary( unsigned ch...

Using Boost.Thread headers with MSVC Language Extensions disabled

I just discovered that when Language Extensions are disabled in MSVC, you get this error if you try to include boost/thread/thread.hpp: fatal error C1189: #error : "Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS" It seems that when Boost detects that language extensions are disabled (_MSC...

Does link line order for supc++ really matter?

Hello, This is a follow up to an earlier question - http://stackoverflow.com/questions/1227615/how-to-use-a-different-stl-with-g I can now get my code to build while using a different STL. However, I still need to link -lsupc++ (along with said different STL) I see anecodal references that -lsupc++ should be the last library on the ...