c++

PIN or Valgrind with Managed C++?

I was wondering what experiences you have had using instrumentation tools with managed C++? PIN: http://www.pintool.org/ Valgrind: http://www.valgrind.org Thanks. ...

VS 7.1 Release compile and multiple threads

VS 7.1 release mode does not seem to be properly parallelizing threads while debug mode does. Here is a summary of what is happening. First, for what it's worth, here is the main piece of code that parallelizes, but I don't think it's an issue: // parallelize the search CWinThread* thread[THREADS]; for ( i = 0; i ...

Should I be leery of using boost::archive?

I want to use boost::archive::iterators::base64_from_binary. But I can't seem to figure out why it is under "archive." What does this imply? Should I be leery of using this code for any reason? Thanks-- ...

C++ system function hangs application

I have the following code void reportResults() { wstring env(_wgetenv(L"ProgramFiles")); env += L"\Internet Explorer\iexplore.exe"; wstringstream url; url << "\"\"" << env.c_str() << "\" http://yahoo.com\""; wchar_t arg[BUFSIZE]; url.get(arg, BUFSIZE); wcout << arg << endl; _wsystem(arg); } Where...

Does GCC have a built-in compile time assert?

Our existing compile-time assert implementation is based on negative array index, and it provides poor diagnostic output on GCC. C++0x's static_assert is a very nice feature, and the diagnostic output it provides is much better. I know GCC has already implemented some C++0x features. Does anyone know if static_assert is among them and if...

Is there a better way to load in a big animation?

Maybe not really big, but a hundred frames or something. Is the only way to load it in by making an array and loading each image individually? load_image() is a function I made which loads the images and converts their BPP. expl[0] = load_image( "explode1.gif" ); expl[1] = load_image( "explode2.gif" ); expl[2] = load_image( "explode3.g...

Dividing C++ Application into Libraries

My C++ project is growing larger. We are also moving to using cmake for building now. I want to divide the application into libraries so that they can be linked for testing, preparing the application package, etc. Right now I would divide my code into libraries as follows: core GUI utilities (these are used by core and other components...

In C++ is "const" after type ID acceptable?

My co-worker is 0 for 2 on questions he has inspired (1, 2), so I thought I'd give him a chance to catch up. Our latest disagreement is over the style issue of where to put "const" on declarations. He is of the opinon that it should go either in front of the type, or after the pointer. The reasoning is that this is what is typically do...

Take the address of a one-past-the-end array element via subscript: legal by the C++ Standard or not?

I have seen it asserted several times now that the following code is not allowed by the C++ Standard: int array[5]; int *array_begin = &array[0]; int *array_end = &array[5]; Is &array[5] legal C++ code in this context? I would like an answer with a reference to the Standard if possible. It would also be interesting to know if it mee...

Using a DLL in Visual Studio C++

I have a DLL that I've been using with no problem in Visual C# (simply adding the reference and using the namespace). Now I'm trying to learn C++, and I don't understand how you reference a namespace from a DLL. I can right-click on a project and select 'references' and from there click 'add new reference', but that just provides me with...

Using CList in a multithreaded environment

I am using a CList in a multithreaded environment and I keep having problem with the GetHead method. I have one thread that add data to the list, and an other thread who read and remove data from the list. Here is the reading part : value_type get_next() { T t; if(!queue.IsEmpty()) { t = queue...

Is using unsigned integer overflow good practice?

I was reading the C Standard the other day, and noticed that unlike signed integer overflow (which is undefined), unsigned integer overflow is well defined. I've seen it used in a lot of code for maximums, etc. but given the voodoos about overflow, is this considered good programming practice? Is it in anyway insecure? I know that a lot ...

App to read form document (scantron-ish)

Hi all, I need to create form that will be filled in by hand and read digitally. I plan on using a sort of scantron-esque format with rows and columns that the user can just color in the a circle in the appropriate cell and the computer will know that value based on the xy position in the cell matrix. Like an excel address. | S...

Predicting that the program will crash

I've been using Google Chrome for a while now and I noticed that it features very elegant crash control. Just before crashing, google chrome gave a message saying "Woah! Google Chrome has crashed. Restart now?". And right after, I'd get a standard Windows XP "This program has encountered a problem and needs to close." with the "Debug",...

How to overload a destructor?

How do I overload a destructor? ...

Example for boost shared_mutex (multiple reads/one write)?

I have a multithreaded app that has to read some data often, and occasionally that data is updated. Right now a mutex keeps access to that data safe, but it's expensive because I would like multiple threads to be able to read simultaneously, and only lock them out when an update is needed (the updating thread could wait for the other thr...

How can I make "real-time" plots with wxMathPlot?

I am thinking of using wxMathPlot for plotting/graphing some data that arrives continuously. I want to draw "Real-time" plot/graph using it. Is that possible? I.E. I don't want just a static graph of a one-time read of a file - I want the streaming data plotted and continued out to the right of the graph - (and let the left side fall...

Is the linked list only of limited use?

I was having a nice look at my STL options today. Then I thought of something. It seems a linked list (a std::list) is only of limited use. Namely, it only really seems useful if The sequential order of elements in my container matters, and I need to erase or insert elements in the middle. That is, if I just want a lot of data and ...

c++ set versus vector + heap operations for an A* priority queue

When is using a std::set more efficient (w.r.t. time) than using a std::vector along with make_heap/push_/pop_ for the priority queue in an A* operation? My guess is that if the vertices in the open list are small, using a vector is a better option. But does anyone have experience with this? ...

How to define preprocessor directives in VC++ 2008?

I'm using Visual C++ 2008 Express Edition. The WIN32 preprocessor directive doesn't appear to be defined by default, so when I surround includes with #ifndef WIN32, it still includes them. I found someone with the exact same problem below, but it was so long ago that the location of this setting has changed: http://www.gamedev.net/comm...