c++

Blocking function call

Hello, I am writing a small test application to test a communication interface. The communication interface is written in C++ (a DLL) and the test application using C#. The communication interface in turn talks to a low level hardware stack which uses windows messages to transmit and receive data. In order to achieve this, the commuicat...

C++ #pragma pack

What does the following statement actually do and what are it's effects? #pragma pack(push,8) ...

Auto correction , auto complete features

Hii , We see suggestions when we type a word in Ms-word , google etc... How do they do that ? I would like to know how the techniqueslike auto correct , auto complete , spell checking etc.. are performed . HOw are the words actually stored... what algorithms are followed ... ??? Any links that suggest a possible way are welcome, ...

Can this if-else statement be made cleaner

I am trying to improve a C++ assignment to make it more efficient. I am a beginner with the language (and programming in general too), so I am only using what I know so far (if, else). I have a function that converts scores into levels, so anything under 30 = 1, 30-49 = 2, 50-79 = 3 and so on... Here is how I am doing it: if (score1 ...

C/C++ Serialize Fast : Boost vs Cpickle vs Json vs Protocol buffer

Hi, I need to serialize C/C++ structure in a binary string,very fast. Env = Windows,Boost 1.44,Python 2.4. We have 3 structures differents to serialize: Basic : int,double,long,float,string (or char*) Vector: - Each element can be : Basic or Vector or a Map --> vector< Basic,Vector,Map > Map: - Each Value element c...

How to call a lib written in C++ from C ?

It seems to me like a no-brainer, but I cannot find any information against or for it. From the point of view of demangling etc, I don't suppose this to be a big problem, but I can't figure out, how I can write a little tiny C program which calls a function from a little tiny C++ library. I am on linux right now, trying with static bin...

What do I have to learn to create Mafia 3 ?

I am a newbie C++ developer for Ubuntu and Windows. I want to know, what other things ( what 3d engine for example ) I have to learn to create a game like Mafia 2 or GTA IV. ...

C++ linking to libraries with makefile (newbe)

Hi, I'm trying to understand how to use non standard libraries in my C++ projects. I have a few questions. Lets say I want to use POCO library. So I downloaded it and build it using make (static build). Now I have bunch of .o files and .h files. There is a Path.h file and a Path.o file in different directories. Now I want to use this m...

Intializing struct data members of a class

typedef struct _MY_STRUCT { std::string mystring; int n1; int n2; } MY_STRUCT; class foo { public: foo(): m_mystruct() { } private: MY_STRUCT m_mystruct; }; int main(void) { foo oFoo; // Why doesnt this intialize all data me...

Can templates such as boost::mpl::integral_c be registered with Boost.Typeof?

boost::mpl::integral_c is declared as: template <typename T, T N> struct integral_c; Is it possible to register this sort of template with Boost.Typeof: For any T? For some T's? ...

Overlapped WSARecv() Callback Not Being Called in MFC App

I have a COM component, implemented in C++ with ATL, that uses overlapped socket I/O. Right after the connection is made to the server, it starts an overlapped read on the socket, with code like this: // Pass pointer to this instance as hEvent parameter, for use by callback m_recvOverlapped.hEvent = reinterpret_cast<HANDLE>(this); int...

What data structure to use?

Hello, I need a data structure with the following properties: Access to elements must be very fast Elements, that are not added, shouldn't take memory (as ideal, size of empty structure near to zero) Each element has two integer coordinates (x,y) (access to elements only by them) Max count of elements known at creation time (over 10^3)...

operator<< for nested class

I'm trying to overload the << operator for the nested class ArticleIterator. // ... class ArticleContainer { public: class ArticleIterator { // ... friend ostream& operator<<(ostream& out, const ArticleIterator& artit); }; // ... }; If I define operator<< like I usual...

Win32 GetOpenFileName prevents app from exiting

Hi, I'm using Win32 with C++ to make an app that can load the contents of files through a dialog with the GetOpenFileName function. Everything works fine, except when I close the main window and the app quits and prints this to the console: The thread 'Win32 Thread' (0xa50) has exited with code 0 (0x0). But the main process keeps runn...

how to dynamically create methods to operate on class objects initialized at runtime

I have a class, say class AddElement{ int a,b,c; } With methods to set/get a,b,c... My question is definitely a logic question - say I implement AddElement as follows: int Value=1; Value+=AddElement.get_a()+AddElement.get_b()+AddElement.get_b(); Now imagine I want to do the above except 'a,b,c' are now arrays, and instead of '...

boost_assert that a parameter class implements a certain method

Hi, Suppose you have a certain template that takes a parameter class template <typename ConnectorClass> struct myClass { } I want to add a BOOST_ASSERT_MSG to validate that ConnectorClass implements a certain method of signature returnType MethodName(param1, param2) How should i write the assert condition in this case? EDIT: si...

Why is inlining considered faster than a function call?

Now, I know it's because there's not the overhead of calling a function, but is the overhead of calling a function really that heavy (and worth the bloat of having it inlined) ? From what I can remember, when a function is called, say f(x,y), x and y are pushed onto the stack, and the stack pointer jumps to an empty block, and begins ex...

What are the default APPDATA directories each version of Windows?

Is there a list of default APPDATA directories each version of Windows? (XP & up) I need to know the default directory each OS will return for the following call: SHGetSpecialFolderLocation( NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE , &pidl ); ...

PostgreSQL's libpq: Encoding for binary transport of ARRAY[]-data ?

Hello, after hours of documentations/boards/mailinglists and no progress I may ask you: How do I 'encode' my data to use it for binary transport using libpq's PQexecParams(.) ? Simple variables are just in big endian order: PGconn *conn; PGresult *res; char *paramValues[1]; int paramLengths[1]; int paramFormats[1]; conn = PQconnectdb...

C++ circular reference problem

Hello, I have 2 classes: DataObject and DataElement. DataObject holds pointers to (only) DataElements, and a DataElement contains pointers to several types, among which a DataObject. This used to be no problem, since I only use pointers to DataObjects in DataElement, so a forward declaration of DataObject in the header of DataElement i...