c++

Visual Studio: Garbled debug watch of std::string's ?

When I'm debugging C++ mixed (managed/unmanaged) projects in Visual Studio 2005, I often get weird data from the debug watches, like below : (btw, the variable i_processName is a const std::string & ) Note that the variable actually holds valid data - if i print it to stdout, the printed string is just fine, thanks for asking. The sim...

replace C style comments by C++ style comments

How can I automatically replace all C style comments (/* comment */) by C++ style comments (// comment)? This has to be done automatically in several files. Any solution is ok, as long as it works. ...

Does the termination condition of a 'for loop' refresh in VC++ 6?

for (int i = 0 ; i < stlVector.size() ; i++) { if (i == 10) { stlVector.erase(stlVector.begin() + 5 ) } } Does the termination condition part "stlVector.size()" take "stlVector.erase(...)" into consideration? In other word does stlVector.size() refresh for every loop iteration? I can't test it right now, so i post...

google code cache-table at VC 2005

I'm trying to compile google cache-table using Visual Studio 2005 and remains one issue : \mm\cache_table.hpp(734) : error C2780: 'void std::_Destroy(_Ty *)' : expects 1 arguments - 2 provided c:\arquivos de programas\microsoft visual studio 8\vc\include\xmemory(58) : see declaration of 'std::_Destroy' \mm\cache_table.hpp(714) : while c...

Simple boost submissions; advice?

Looking for some general advice... I've been using boost for a while, and I've written several small modules and function (eg: see this SO question) which I think cold be appropriate for inclusion in boost. I've been to the project pages to see about the submission process, but it seems like it's "be on the inside, or don't bother". I c...

C++ cwchar error

Hi, I am trying to compile the regex_search function on the vxWorks gcc platform. I was testing with an example to see if I can use it without any issues. The example file includes the following three headers. #include <string> #include <map> #include <boost/regex.hpp> The errors I get are as follows include/c++/3.4.4/cwchar:73: er...

Platform-independent GUID generation in C++?

What is the best way to programmatically generate a GUID or UUID in C++ without relying on a platform-specific tool? I am trying to make unique identifiers for objects in a simulation, but can't rely on Microsoft's implementation as the project is cross-platform. Notes: Since this is for a simulator, I don't really need cryptographic...

In the C++ Boost libraries, why is there a ".ipp" extension on some header files

In the C++ Boost libraries, why is there a ".ipp" extension on some header files? It seems like they are header files included by the ".hpp" file of the same name. Is this convention common outside of Boost? What is the justification for having a special file type? ...

Structs vs classes in C++

When should someone use structs instead of classes or vice versa in C++? I find myself using structs when a full-blown class managing some information seems like overkill but want to indicate the information being contained are all related. I was wondering what are some good guidelines to be able to tell when one is more appropriate th...

getopt() in VC++

I'm quite fond of using GNU getopt, when programming under Linux. I understand, that getopt(), is not available under MS VC++. Note: Win32 environment using Visual Studio No Boost No MFC Not concerned with portability Question: How can I then port getopt() accordingly? What guidelines should I be aware of while porting? Known po...

#include all .cpp files into a single compilation unit?

I recently had cause to work with some Visual Studio C++ projects with the usual Debug and Release configurations, but also 'Release All' and 'Debug All', which I had never seen before. It turns out the author of the projects has a single ALL.cpp which #includes all other .cpp files. The *All configurations just build this one ALL.cpp f...

Calculate SLOC GCC C/C++ Linux

Hi, We have a quite large (280 binaries) software project under Linux and currently it has a very dispersed code structure - that means one can't [work out] what code from the source tree is valid (builds to deployable binaries) and what is deprecated. But the Makefiles are good. We need to calculate C/C++ SLOC for entire project. Here...

How do I use glutBitmapString() in C++ to draw text to the screen?

I'm attempting to draw text to the screen using GLUT in 2d. I want to use glutBitmapString(), can someone show me a simple example of what you have to do to setup and properly use this method in C++ so I can draw an arbitrary string at an (X,Y) position? glutBitmapString(void *font, const unsigned char *string); I'm using linux, and ...

Is it possible (or ok) to have a std::list of std::list's?

I have a std::list of Points (that simply store an x, y). Each one of these points represents a polygon, which I later draw. class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; std::list <Point> currentPolygon; I would like to have a list of these polygons (lists themselves). ...

C++ wrappers for ncurses?

Can anyone recommend a C++ wrapper for ncurses? ...

Junior Engineer Interviewing Senior Engineer - Need Questions

I am a Junior Engineer with under a year experience, primarily as a UI developer. We have a former Lead Programmer who just got laid off who is interviewing at our company, and I am one of the people interviewing him. He has almost 25 years of experience, so obviously it will be pointless to ask him technical questions. As a junior prog...

Concat strings and numbers in C++?

I'm trying to concat "(" + mouseX + ", " + mouseY ")". However, mouseX and mouseY are ints, so I tried using a stringstream as follows: std::stringstream pos; pos << "(" << mouseX << ", " << mouseY << ")"; _glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str()); And it doesn't seem to work. I get the following error: mouse.cpp:7...

Global variables and scope - C++

I am having small problem in making a global variable works. I am using Visual Studio 2008 and standard C++. I have two projects, one is a static library and second one is a test program which uses this library. I have a global variable in global.h like #ifndef GLOBAL_H #define GLOBAL_H #include <string> extern std::string globalWo...

Trouble with pointers and references in C++

I have a PolygonList and a Polygon type, which are std::lists of Points or lists of lists of points. class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; typedef std::list<Point> Polygon; typedef std::list<Polygon> PolygonList; // List of all our poly...

C++: typedef-ing STL

Instead of using std::vector<Object> ObjectArray; I would like it to be MyArray<Object> ObjectArray; with all the std::vector methods preserved. (like push_back(), reserve(), ...etc) However, using typedef std::vector MyArray; won't work. Should I use template instead? How? Thanks in advance. ...