c++

Clean up your #include statements?

How do you maintain the #include statements in your C or C++ project? It seems almost inevitable that eventually the set of include statements in a file is either insufficient (but happens to work because of the current state of the project) or includes stuff that is no longer needed. Have you created any tools to spot or rectify proble...

Stroustrup swan book Vector Problem

I'm using Stroustrup's swan book. I have run into a problem getting output from a vector. I followed the text example from sec. 4.6.3 on page 121. I managed to get the source compiled and am able to execute it. After typing in a list of whitespace separated words, the program hangs and does not list the elements of the vector as it shoul...

How to create two mains in an eclipse C++ project

We've got a program which runs separately, executed with an execvp command. So it needs a main method, but I believe that poses a problem to eclipse with a managed make. Do we have to keep this code segregated into a separate project, or is there a way to incorporate it into the same eclipse project? ...

C++ Container / Iterator Dependency Problem

Hello :) I'm working on an container class that looks something like this: class hexFile { public: HANDLE theFile; unsigned __int64 fileLength; hexFile(const std::wstring& fileName) { theFile = CreateFile(fileName.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FI...

Interval in c++

Hello, I have a 44100 samples audio data at the moment but this will be larger in size. This is saved in a file. I would like to make a interval of these while reading this from a file and doing some more mathematical operations. The interval will be repeated in the middle point until several levels. I was thinking about this but I us...

Can I create a software watchdog timer thread in C++ using Boost Signals2 and Threads?

I am running function Foo from somebody else's library in a single-threaded application currently. Most of the time, I make a call to Foo and it's really quick, some times, I make a call to Foo and it takes forever. I am not a patient man, if Foo is going to take forever, I want to stop execution of Foo and not call it with those argum...

C++ Library for session management?

This is in reference to question How to maintain sessions with C++ code? Is there a C++ library (like Boost) available to manage sessions for web based CGI applications? How feasible is it to make use of Cookies and URL Rewriting in C++ code for web based CGI applications? ...

Static Class Variable, Exported From DLL, Shows as Memory Leak

Alright, I have an exported class within a DLL. This class has a list of static strings, which are used in a ComboBox of a Dialog within the importing process. These strings are declared and defined as follows: // In header: class MYDLL_API someClass { public: static const string stringList[]; static const int numString; }; // ...

boost:spirit reuse rules

Hej, another question: I have written a number of very similar parsers which use a number of common rules. Can I store these rule<> objects in a place where they can be acessed by multiple parsers? It looks somehow like this: rule<> nmeaStart = ch_p('$'); rule<> nmeaAddress = alnum_p() >> alnum_p() >> !alnum_p() >> !alnum_p(); rule<> n...

GCC How to export a function from static library

Hi, I want to create a shared library from several static libs using GCC under OS X. In some static libs, there's no code in shared library call it, I just want to export the symbols in these static libs. This works under debug mode, but doesn't under release mode (especially when I enable the dead code striping). I can understand the ...

Linking in test libraries with CppUnit

I'm setting up a bunch of unit tests using CppUnit but am having the problem that none of the tests are being run. The project is divided up into several small libraries and I planned on dividing the unit test classes up the same way and then linking them all into a single test program. The problem is, then the test classes are in thei...

List Iterator Remove()

I have a list iterator that goes through a list and removes all the even numbers. I can use the list iterator to print out the numbers fine but I cannot use the list's remove() and pass in the dereferenced iterator. I noticed that when the remove() statement is in effect, *itr gets corrupted? Can somebody explain this? #include <iostre...

setting _HAS_ITERATOR_DEBUGGING to 0

How can i set _HAS_ITERATOR_DEBUGGING to 0 I tried setting using #define _HAS_ITERATOR_DEBUGGING 0 at the start of the main.cpp I tried in setting preprocessor definition :( but with no success Thanks in advance Uday ...

Why C++ allows arithmetic or enumeration values to be implicitly converted to boolean?

C++ standard says in section 4.12, An rvalue of arithmetic, enumeration, pointer, or pointer to member type can be converted to an rvalue of type bool. A zero value, null pointer value, or null member pointer value is converted to false any other value is converted to true. Which means that the following code is valid, if(5) std::co...

Is there any direct way to do what pin_ptr does?

Can the behaviour of pin_ptr be achieved directly in C++/CLI? For example, is it possible to write CLR code directly, something like asm for native apps? An example of what I would like to do is a wrapper for a pin_ptr (impossible because of the restrictions on pin_ptrs). class WrappedPtr { public: explicit WrappedPtr(String^ s) ...

Building GMP library with Visual Studio?

Is there an easy way to build the GMP (GNU Multiple Precision Arithmetic Library, http://gmplib.org) under Windows, using Visual Studio 2005? I tried to find information about building the library myself, but could not find anything that really helped me. I'm not very experienced with building libraries myself (I've managed to build boos...

Returning struct from a function, how can I check that it is initialized?

I have the following struct in C++: struct routing_entry { unsigned long destSeq; // 32 bits unsigned long nextHop // 32 bits unsigned char hopCount; // 8 bits }; And I have the following function: routing_entry Cnode_router_aodv::consultTable(unsigned int destinationID ) { routing_entry route; if ( routing_table.f...

Can't find MSVCP80.dll (side by side problem?)

Hi, when I try to start the release-version of my project from visual studio 2005 (SP1) I get the following error message: "This application has failed to start because MSVCP80.dll was not found. Re-installing the application may fix this problem" When I look at the manifest for the release version it specifies the following: <?xml v...

C++ static const variable and destruction

Hi, I have encountered a strange behavior with a simple C++ class. classA.h class A { public: A(); ~A(); static const std::string CONST_STR; }; classA.cpp #include "classA.h" #include <cassert> const std::string A::CONST_STR("some text"); A::A() { assert(!CONST_STR.empty()); //OK } A::~A() { assert(!CONST_STR.empty());...

#error WINDOWS.H already included. MFC apps must not #include <windows.h>

Hi I am getting #error WINDOWS.H already included. MFC apps must not #include windows.h But i dont know how do i find out because of which file this is happening Thanks ...