c++

How can I check that I didn't break anything when refactoring?

I'm about to embark on a bout of refactoring of some functions in my code. I have a nice amount of unit tests that will ensure I didn't break anything, but I'm not sure about the coverage they give me. Are there any tools that can analyze the code and see that the functionality remains the same? I plan to refactor some rather isolated...

I get an exception if I leave the program running for a while

Platform : Win32 Language : C++ I get an error if I leave the program running for a while (~10 min). Unhandled exception at 0x10003fe2 in ImportTest.exe: 0xC0000005: Access violation reading location 0x003b1000. I think it could be a memory leak but I don't know how to find that out. Im also unable to 'free()' memory because ...

do sem_wating threads cause more switching

I have several threads which act as backup for the main one spending most of their life blocked by sem_wait(). Is it OK to keep them or is it better to spawn new threads only when they need to do actual work? Does kernel switch to threads waiting on sem_wait() and "waste" CPU cycles? Thanks. ...

getopt for Visual Studio CRT?

Is there an equivalent to getopt() in the visual studio CRT? Or do I need to get it and compile it with my project? Edit clarification getopt is a utility function in the unix/linux C Run Time library for common command line parsing chores i.e. parsing arguments of the form -a -b -f someArg etc' ...

MVC model in MFC

how are the classses in MFC match the model-view-control pattern ? the model is suppose to handle the Business Logic , the control suppose to be some kind of mediator and the view suppose to be the gui ? what class in MFC represent each one ? cause it seems pretty different to me as i read more about mfc. (seems like CView represent th...

what Applications can you make with the programming language Ruby?

What applications can you make with the programming language Ruby? Can you name a few commercial/famous ones written only in Ruby? What I'd really like to know is can you just learn Ruby instead of C/C++ to make commercial software e.g web server, photoshop, desktop applications, even an operating system etc. Except Ruby on Rails whic...

C++ design: How to cache most recent used

Hi We have a C++ application for which we try to improve performance. We identified that data retrieval takes a lot of time, and want to cache data. We can't store all data in memory as it is huge. We want to store up to 1000 items in memory. This items can be indexed by a long key. However, when the cache size goes over 1000, we want to...

[C++] Error linking with C++

I've try to compile this code: #include <iostream> #include <cstdlib> using namespace std; #define ARRAY_TAM 2 typedef int (*operacion)(int, int); typedef const char* (*Pfchar)(); int suma(int, int); int resta(int, int); const char* descrSuma(); const char* descrResta(); const char* simbSuma(); const char* simbResta(); class OP { ...

basic playback with programmatically created windows media player

I was trying to "just quickly integrate" the Windows Media Player via COM to play single files from the local file system or http sources - but due to the sparse documentation and online resources to its usage when not embedding into some kind of an Ole container, i couldn't get that supposedly trivial use-case to work. Initialization e...

running external .exe on button click c++. How to??

I am creating a simple GUI in C++ which have few buttons in it. I want to launch some external .exe files when i click on these buttons. What's the code to achieve this? ...

How can I create a std::vector with 64 bit indexes?

I want to create a big std::vector so operator[] should receive long long rather than unsigned int, I tried writing my own allocator: template <typename T> struct allocator64 : std::allocator<T> { typedef long long difference_type; typedef unsigned long long size_type; }; But when I try the following: long long n = 5; std::ve...

no std namespace

We've got a reasonable sized C++ application that's pretty old at this stage, so it's got a few quirks. One of these quirks is in how it deals with C++ compilers that use a pre-standisation standard library. There's one header file that's supposed to resolve any differences between a standards compliant compiler and this one non-compl...

Problem with boost memory mapped files: they go to disk instead of RAM

I am trying to understand how Boost memory mapped files work. The following code works, it does what it is supposed to do, but the problem is that the file it generates is stored on disk (in the same directory of the executable) instead of memory. Maybe there is a flag to set somewhere, but I could not find it... Thanks in advance for an...

What is a good way to add MFC gui to a Win32 C++ command line application?

We have a command line application that could benefit from a GUI. We want to add some plotting functionality and have identified a plotting library that uses MFC. Initially we developed a separate app, but we'd rather have the GUI in the same process space. I was thinking of possibly a GUI in an MFC DLL that could be hosted in the p...

C++ [] array operator with multiple arguments?

Can I define in C++ an array operator that takes multiple arguments? I tried it like this: const T& operator[](const int i, const int j, const int k) const{ return m_cells[k*m_resSqr+j*m_res+i]; } T& operator[](const int i, const int j, const int k){ return m_cells[k*m_resSqr+j*m_res+i]; } But I'm getting this error: error C28...

c++ () operator problem

I've got another problem when trying to overload the () operator for array access: const OctTreeNode*& operator()(const int i, const int j, const int k) const{ return m_cells[k*m_resSqr+j*m_res+i]; } OctTreeNode*& operator()(const int i, const int j, const int k){ return m_cells[k*m_resSqr+j*m_res+i]; } vector<OctTreeNode*> m_ce...

Tips for embedding a longer text in source code, as in languages like Perl?

Possible Duplicate: Something like print END << END; in C++? In a shell script or in a perl program the so called "HERE" documents are commonly used for longer text, e.g. Perl: my $t=<<'...'; usage: program [options] arg1 arg2 options: -opt1 description for opt1 -opt2 description for opt2 ...

How to support linux for my C# project

Hello everyone, I have a project that is an open source application for a specific type of scientific calculation that uses c++ for the backend, and C# for the front end. I'm not doing anything windows specific in the c++ portion, so I'm hoping for a relatively small learning curve there. I have a few specific questions, and I would appr...

Segfault in atoi(str)

I'm new to the C/C++ game so I assume I'm making a rookie mistake: int main(){ char* clen; clen = getenv("CONTENT_LENGTH"); if (clen==NULL){ cout << "No such ENV var: CONTENT_LENGTH"<<endl; exit(0); } int cl = 0; cl = atoi(clen); if (cl < 1){ return inputPage(); } // if there is no content, we assume tha...

Storing an integer into a char* in C++

I'm writing some code that returns an integer, which then needs to be outputted using printw from the ncurses library. However, since printw only takes char*, I can't figure out how to output it. Essentially, is there a way to store a integer into a char array, or output an integer using printw? ...