c++

GCC and ld can't find exported symbols...but they're there!

I have a C++ library and a C++ application trying to use functions and classes exported from the library. The library builds fine and the application compiles but fails to link. The errors I get follow this form: app-source-file.cpp:(.text+0x2fdb): undefined reference to `lib-namespace::GetStatusStr(int)' Classes in the library see...

extern inline

I understand that "inline" by itself is a suggestion to the compiler, and at its descretion it may or may not inline the function, and it will also produce linkable object code. I think that "static inline" does the same (may or may not inline) but will not produce linkable object code when inlined (since no other module could link to i...

Pros and cons of using nested C++ classes and enumerations?

What are the pros and cons of using nested public C++ classes and enumerations? For example, suppose you have a class called printer, and this class also stores information on output trays, you could have: class printer { public: std::string name_; enum TYPE { TYPE_LOCAL, TYPE_NETWORK, }; class out...

What's the best way to trim std::string

I'm currently using the following code to right-trim all the std::strings in my programs: std::string s; s.erase(s.find_last_not_of(" \n\r\t")+1); It works fine, but I wonder if there are some end-cases where it might fail? Of course, answers with elegant alternatives and also left-trim solution are welcome. ...

Partial sort of std::list

I have a linked list that I want to sort part of, eg: std::sort(someIterator, otherIterator, predicate); std::sort requires random-access iterators so this approach doesn't work. There is a specialisation std::list::sort, but that can only sort the entire list. I don't think I have enough access to the list members to write something ...

C++ STL: Container Recreation or Reuse after clearing?

In programming we face various situations where we are required to make use of intermediate STL containers as the following example depicts: while(true) { set < int > tempSet; for (int i = 0; i < n; i ++) { if (m.size() == min && m.size() <= max) { tempSet.insert(i); } } //Some co...

Missing msvcr80.dll

If the C++ runtime msvcr80.dll is missing from a compiled library, is there any way to determine which version was used to create the library or to get it to run on a later version of msvcr80.dll? ...

How do you configure the email settings in CrashRpt to send the crash dump?

After reading this discussion and this discussion about using CrashRpt to generate a crash dump and email it to the developers, I've been having a difficult time finding any instructions/tutorials for configuring the email settings used by the library to send the email. When you call the install() function to initialize CrashRpt, you sp...

What are the possible classes for the OpenThemedata function?

Hi Everybody, I'm trying to call the OpenThemeData (see msdn OpenThemeData) function but I couldn't determine what are the acceptable Class names to be passed in by the "pszClassList" parameter. HTHEME OpenThemeData( HWND hwnd, LPCWSTR pszClassList ); Could anybody tell me what are the acceptable class names that I can pass in...

Which Typesafe Enum in C++ Are You Using?

It is common knowledge that built-in enums in C++ are not typesafe. I was wondering which classes implementing typesafe enums are used out there... I myself use the following "bicycle", but it is somewhat verbose and limited: typesafeenum.h: struct TypesafeEnum { // Construction: public: TypesafeEnum(): id (next_id++), name("") {} ...

What is a safe equivalent of non-void STL erase?

Suppose I have a hash_map and a code like // i is an iterator i = hash_map.erase(i) But GCC's STL doesn't return iterator in erase, but a void. Now is a code like hash_map.erase(i++) safe (i.e. does not invalidate the iterator or does any other unexpected or unpleasant things)? Please note this is a hash_map. ...

c++ template function overloading.

Below are lines from "the c++ programming language" template<class T > T sqrt(T ); template<class T > complex<T> sqrt(complex<T>); double sqrt(double); void f(complex<double> z ) { s q r t (2 ); // sqrt<int>(int) sqrt(2.0) ; // sqrt(double) sqrt(z) ; // sqrt<double>(complex<double>) } I dont understand why sqrt(z) ; calls sqrt<double>...

Why don't C++ compilers define operator== and operator!= ?

I am a big fan of letting the compiler do as much work for you as possible. When writing a simple class the compiler can give you the following for 'free': A default (empty) constructor A copy constructor A destructor An assignment operator (operator=) But it cannot seem to give you any comparison operators - such as operator== or o...

Searching CStrings in C++

Hi all, I was wondering if there is a native C++ (or STL/Boost) function which will search a CString for a specified string? e.g. CString strIn = "Test number 1"; CString strQuery = "num"; bool fRet = SomeFn(strIn, StrQuery); if( fRet == true ) { // Ok strQuery was found in strIn ... I have found a small number of functions lik...

Simple C++ MIME parser

I want to digest a multipart response in C++ sent back from a PHP script. Anyone know of a very lightweight MIME parser which can do this for me? Regards Robert ...

Visual C++ 2008 'Release' build contains debug information

I've noticed that when generating a new C++ project using MS Visual Studio 2008, the Release build contains debugging symbols - specifically the following settings are enabled: The C++/General/Debug Information Format is set to Program Database. The Linker/Debugging/Generate Debug Info setting is set to Yes. I have never noticed this...

Finding "best matching key" for a given key in a sorted STL container

Problem I have timestamped data, which I need to search based on the timestamp in order to get the one existing timestamp which matches my input timestamp the closest. Preferably this should be solved with the STL. boost::* or stl::tr1::* (from VS9 with Featurepack) are also possible. Example of timestamped data: struct STimestampedDat...

MSVCR90D.dll not found in debug mode with Visual C++ 2008

Hello, I have a problem with Visual C++ 2008. I have installed opencv and I've created a new program and I build it with no errors. However, it complains about not finding MSVCR90D.dll when debugging. In release mode there is no problem at all. I do have MSVCR90D.dll in one of Winsxs folders. Does anyone know a get-around to this prob...

Concurrent programming c++?

I keep on hearing about concurrent programing every where. Can you guys throw some light on what it's and how c++ new standards facilitate doing the same? ...

Simple Model Checker Tool

Is there a simple Model Checker tool. I am planning to implement a model checker tool which will analyze the code for some of the predefined properties. ...