c++

Portable and simple unicode string library for C/C++?

I'm looking for a portable and easy-to-use string library for C/C++, which helps me to work with Unicode input/output. In the best case, it will store its strings in memory in UTF-8, and allow me to convert strings from ASCII to UTF-8/UTF-16 and back. I don't need much more besides that (ok, a liberal license won't hurt). I have seen th...

Running background services on a PocketPC

Hi, I've recently bought myself a new cellphone, running Windows Mobile 6.1 Professional. And of course I am currently looking into doing some coding for it, on a hobby basis. My plan is to have a service running as a DLL, loaded by Services.exe. This needs to gather som data, and do som processing at regular intervals (every 5-10 minut...

Minimal XML library for C++?

What XML libraries are out there, which are minimal, easy to use, come with little dependencies (ideally none), can be linked statically and come with a liberal license? So far, I've been a pretty happy user of TinyXML, but I'm curious what alternatives I have missed so far. ...

Editing the IDL created by OLE view for a C++ component

What things do I need to consider when doing this: What to remove/manipulate/add Regards ...

(Encoded) String handling in C++ - questions / best practices?

What are the best practices for handling strings in C++? I'm wondering especially how to handle the following cases: File input/output of text and XML files, which may be written in different encodings. What is the recommended way of handling this, and how to retrieve the values? I guess, a XML node may contain UTF-16 text, and then I ...

Two basic C++ questions about string literals and dynamic allocation

Are these two equivalent? char * aString = "This is a string."; char aString[] = "This is a string."; From my understanding, C++ stores strings by their addresses, so the pointer is getting a valid address. I assume the strings are also stored as type char? But how does it know how much memory to allocate for the string? Normally, cha...

What are some common Java pitfalls/gotchas for C++ programmer?

As the question says, what are some common/major issues that C++ programmers face when switching to Java? I am looking for some broad topic names or examples and day to day adjustments that engineers had to make. I can then go and do an in-depth reading on this. I am specifically interested in opinions of engineers who have worked in C...

Why are C character literals ints instead of chars?

In C++, sizeof('a') == sizeof(char) == 1. This makes intuitive sense, since 'a' is a character literal, and sizeof(char) is defined to be 1 by the standard. But in C, sizeof('a') == sizeof(int). That is, it appears that C character literals are actually integers. Does anyone know why? I can find plenty of mentions of this C quirk but no ...

Protected derived class

#include <iostream> using namespace std; class Base { public: Base(){cout <<"Base"<<endl;} virtual ~Base(){cout<<"~Base"<<endl;} virtual void foo(){ cout<<"foo base"<<endl;} }; class Derived: private Base { public: Derived(){cout<<"Derived"<<endl;} virtual ~Derived(){cout<<"~Derived"<<en...

C library vs WinApi

Hi, Many of the standard c library (fwrite, memset, malloc) functions have direct equivalents in the windows API (WriteFile, FillMemory/ ZeroMemory, GlobalAlloc). Apart from portability issues, what should be used, the CLIB or windows API functions? Will the C functions call the winapi functions or is it the other way around? thanks...

Mac OSX - Xcode/Leaks problem

I'm new to development using Xcode, and am having trouble using the built-in Leaks Instrument. I have enabled guard malloc and put MallocStackLogging YES & MallocStackLoggingNoCompact YES in the environmental variables for the executable. Then running the process by clicking Run->Start with performance tool->Leaks But only object al...

What SDK should I use? c++

I have this program in mind that I would like to attempt and create in c++. I am not sure what SDK I should use, Here is the idea: Basically like Facebooks status' or twitter but strictly for your desktop. Window like AIM or MSN would allow you to view your friends and their current status, allow you to comment on it, etc. When someone ...

Array of structs and new / delete

I have a struct like this: class Items { private: struct item { unsigned int a, b, c; }; item* items[MAX_ITEMS]; } Say I wanted to 'delete' an item, like so: items[5] = NULL; And I created a new item on that same spot later: items[5] = new item; Would I still need to call delete[] to clean this up? Or won't this be needed...

Anyone knows how to fix compile error: LNK2005? (Source Code inside).

I have the below code in stdafx.h. using namespace std; typedef struct { DWORD address; DWORD size; char file[64]; DWORD line; } ALLOC_INFO; typedef list<ALLOC_INFO*> AllocList; //AllocList *allocList; Without the commented code (last line), it compiles just fine. But when I add the commented code, Im getting the fol...

Create user exception derived from std::exception?

How a user exception class is created from standard exception? Addressing below cases Say i have a class with some enum that indicates type of object so based on type, member functions are available.Calling member function that is not available should throw an exception.Similarly when a getter of uninitialized is called again a except...

Normal main to WinCE main

I'm porting an existing (mostly) cross-platform application to WinCE 4.2. The current entry point for the function is int main(int argc, char *argv[]){} I would like to keep this part as-is, and have the WinCE entry point simply call it. I believe something like the following should work: int WINAPI WinMain( HINSTANCE hInstance, ...

Api for indexing and hashing

Hi guys, I am trying to build a prototype of search engine. Can any one please suggest me C++ APIs for indexing and retrieving the data? Thanks ...

What is the best way to store UTF-8 strings in memory in C/C++?

Looking at the unicode standard, they recommend to use plain chars for storing UTF-8 encoded strings. Does this work as expected with C++ and the basic std::string, or do cases exist in which the UTF-8 encoding can create problems? For example, when computing the length, it may not be identical to the number of bytes - how is this suppo...

C++ Linker Error

Hi, I had a function like this, that wasn't within a class: // Gets the maximum number of tracks displayable const utils::uint32 GetConstMaxSystemRange() { return constMaxSystemNumber - constMinSystemNumber + 1; } It compiled fine in VS2005, but then I got linker errors for each file after the first one to include it, even thoug...

Good or Bad C++ Idiom - Objects used purely for constructor/destructor?

I have a few classes which do nothing except in their constructors/destructors. Here's an example class BusyCursor { private: Cursor oldCursor_; public: BusyCursor() { oldCursor_ = CurrentCursor(); SetCursor(BUSY_CURSOR); } ~BusyCursor() { SetCursor(oldCursor_); } } // example of use...