c++

Including boost::filesystem produces linking errors

Ok first off, I am linking to boost_system and boost_filesystem. My compiler is a custom build of MinGW with GCC 4.3.2 So when I include: #include "boost/filesystem.hpp" I get linking errors such as: ..\..\libraries\boost\libs\libboost_system.a(error_code.o):error_code.cpp: (.text+0xe35)||undefined reference to `_Unwind_Resume'...

Making GCC and Other C++ Compilers Very Strict

I'm working on a large collaborative C++ project that is both developed and run on various flavors of Linux, OS X and Windows. We compile across these platforms with GCC, Visual Studio C++ and the Intel C++ compiler. As more and more people start developing code for the project, we're starting to see weird errors in compilation and runti...

How is the C++ exception handling runtime implemented?

I am intrigued by how the C++ exception handling mechanism works. Specifically, where is the exception object stored and how does it propagate through several scopes until it is caught? Is it stored in some global area? Since this could be compiler specific could somebody explain this in the context of the g++ compiler suite? ...

Describing header file locations in makefile

In a new project I am working on I have the following dir structure: Project_base |---- src |---- bin |---- h | Makefile And in my source files I have includes that look like so: #include "../h/SomeHeaderFile.h" instead of the more correct form: #include "SomeHeaderFile.h" What do I need to add to my makefile so that I can remov...

friend class : inherited classes are not friend as well ?

In C++, I have a class A which is friend with a class B. I looks like inherited classes of B are not friend of class A. I this a limitation of C++ or my mistake ? Here is an example. When compiling, I get an error on line "return new Memento": Memento::Memento : impossible to access private member declared in Memento. class Originat...

How to convert standard IP address format string to hex and long?

Hi, Does anyone know how to get the IP address in decimal or hex from standard IP address format string ("xxx.xxx.xxx.xxx")? I've tried to use the inet_addr() function but didn't get the right result. I tested it on "84.52.184.224" the function returned 3770168404 which is not correct (the correct result is 1412741344). Thanks! ...

Where is documentation on the Microsoft Visual Studio C++ Name Mangling Scheme?

I am interested in finding either official or reverse engineered documentation detailing the name mangling scheme used by the Visual Studio C++ Compiler to translate C++ names into symbols in generated code. I am aware that this may change between versions, and am most interested in the details for Visual Studio 2003, 2005 and 2008. Of...

Why Java, C# and C++ don't have ranges?

Ada, Pascal and many other languages support ranges, a way to subtype integers. A range is a signed integer value which ranges from a value (first) to another (last). It's easy to implement a class that does the same in OOP but I think that supporting the feature natively could let the compiler to do additional static checks. I know tha...

Pimpl idiom with inheritance

I want to use pimpl idiom with inheritance. Here is the base public class and its implementation class: class A { public: A(){pAImpl = new AImpl;}; void foo(){pAImpl->foo();}; private: AImpl* pAImpl; }; class AImpl { public: void foo(){/*do something*/}; }; And I want to be able to create the der...

DirectX Font tutorial that doesn't use GDI

Does anyone have any tutorials/info for creating and rendering fonts in native directx 9 that doesn't use GDI? (eg doesn't use ID3DXFont). I'm reading that this isn't the best solution (due to accessing GDI) but what is the 'right' way to render fonts in dx? ...

Levels of Indentation

How many levels of indentation do you consider reasonable? I feel that having a C++ function with 4/5+ levels of indentation is normally a bad thing. It implies that you have to mentally keep track of 4/5+ things the whole time. Is my opinion justified? (yes, I can avoid having multiple levels of indentation by not indenting at all:) ...

Are there general guidlines for solving undefined reference/unresolved symbol issues?

I'm having several "undefined reference" (during linkage) and "unresolved symbol" (during runtime after dlopen) issues where I work. It is quite a large makefile system. Are there general rules and guidelines for linking libraries and using compiler flags/options to evade these types of errors? ...

Howto format a boost::date_time-object as per RFC 3339

I want to use the date_time library in boost to represent time in my application. This application will generate Atom feeds, which in turn mandates time-stamps in the format specified in RFC 3339, for example "1990-12-31T23:59:60Z" or "1990-12-31T15:59:60-08:00". So, how do I format time according to this RFC? I have been reading the D...

Giving to child access to parent's member by reference - is it OK?

C++ newbie question. Please, verify I'm doing it right. I have a global application class spawning it's little kids and I need to give the kids access to some of the application facilities. So I decided to pass them to children by reference. I tested the idea as show below. It seems to work fine. I just wanted to make sure I'm not doin...

Is it possible to treat a template instance as a namespace?

Suppose I have template< unsigned int num > class SomeFunctionality { static unsigned int DoSomething() { //... } static void DoSomethingElse() { } }; typedef SomeFunctionality<6> SomeFunctionalityFor6; Semantically, "SomeFunctionalityFor6" is essentially a namespace specific to the templ...

How to start writing a PHP5 extension in C++

I'm writing a PHP5 extension, and while I could write it in C, it would be easier to use C++ and take advantage of the STL and Boost. Trouble is, the tutorials I've seen only deal with C, and I'm looking for a basic example which uses C++ Here's what I've tried so far: config.m4 [ --enable-hello Enable Hello World support]) if tes...

why doesn't std::string provide implicit conversion to char*?

std::string provides const char* c_str ( ) const which: Get C string equivalent Generates a null-terminated sequence of characters (c-string) with the same content as the string object and returns it as a pointer to an array of characters. A terminating null character is automatically appended. The returned a...

C++ scanner (string-fu!)

I'm writing a scanner as part of a compiler. I'm having a major headache trying to write this one portion: I need to be able to parse a stream of tokens and push them one by one into a vector, ignoring whitespace and tokenizing special symbols (simple case, lets just consider parentheses and braces) Example: int main(){ ...

Free static code scanner for C/C++/C#

Hi! Does anyone know an open-source and/or free code-scanner for automated code analysis in C#, C or C++? I know for Java there's some brilliant stuff like FindBugs (Eclipse integrated), PMD, or Hammurapi. Is there anything similar for the C-languages? wishi ...

Uploading big files over HTTP

I need to upload potentially big (as in, 10's to 100's of megabytes) files from a desktop application to a server. The server code is written in PHP, the desktop application in C++/MFC. I want to be able to resume file uploads when the upload fails halfway through because this software will be used over unreliable connections. What are m...