c++

How to manage object life time using Boost library smart pointers?

Hi, There is a scenario that i need to solve with shared_ptr and weak_ptr smart pointers. Two threads, thread 1 & 2, are using a shared object called A. Each of the threads have a reference to that object. thread 1 decides to delete object A but at the same time thread 2 might be using it. If i used shared_ptr to hold object A's refere...

Excel OpenText method

I keep getting the ambiguous error code of 0x800A03EC.   I've been searching quite a bit to see if I could find a specific reason for the error but unfortunately that code seems to cover a multitude of possible errors. I will copy and paste the code that seems to be giving me problems and hopefully someone will be able to provide me wit...

read matrix from a file in C C++

Hi Just wonder, for a matrix stored in a file as what it is, i.e. each line in the file being a row of the matrix where elements are separated by space(s), how can I predetermine the size of the matrix, then create an array of the same size and read it into the array in C and C++? If you have some code example, that would be appreciated...

c++ templates: header files still broken?

It used to be that to use a template class in C++, the implementations had to be in the header file or #included into the header file at the bottom. I've not used C++ templates for a few years; I just started using them again and observed that this behavior seems to persist. Is this still the case? Or are the compilers smart enough now...

Differences between struct in C and C++

I am trying to convert a C++ struct to C but keep getting "undeclared identifier"? Does C++ have a different syntax for referring to structs? struct KEY_STATE { bool kSHIFT; //if the shift key is pressed bool kCAPSLOCK; //if the caps lock key is pressed down bool kCTRL; //if the control key is pressed down bool kALT;...

cudaSafeCall() runtime API error

I am trying to run CUDA in emulation mode in Visual Studio 2008. It is showing this problem at runtime- cudaSafeCall() Runtime API error in file , line abc : feature is not implemented for example in one case it turned out to be this one- cutilSafeCall(cudaGLRegisterBufferObject(pbo)); and if i commented this one out then- cutilSafeC...

Python/C++ Binding Library comparison

I feel as though this question is a duplicate, but I haven't found one on the subject (specifically) yet so I'll ask anyway: What Python/C++ binding libraries would you recommend and why? In addition, what has been your experience using it or any others you have tried? Also, what binding features do they contain and has your use of them...

How do you get what kind of encoding your system uses in c/c++?

In linux terminal one would type locale charmap in order to see what kind of character-encoding your system uses, eg UTF-8. My question is how would you do this using c/c++. (I'm using linux) edit: I tried using nl_langinfo(CODESET) but I got ANSI_X3.4-1968 instead of UTF-8 (which is what I get when typing: locale charmap). Am I...

Compiling an application that uses WinUsb

I am in the process of writing an application to communicate with Usb devices using WinUsb.dll. This is a user-mode library that allows communication with a device through winusb.sys installed as its driver in the kernel. I am writing this application in C++ with Visual Studio 2008. The header WinUsb.h is found in the Windows DDK so I ...

What happens if I ReleaseMutex() twice?

The Microsoft documentation is silent about what happens if I mistakenly call ReleaseMutex() when the mutex is already unlocked. Details: I'm trying to fix up some Windows code without having access to the compiler. I realise that WinApi mutexes are all recursive, and reference-counted. If I were making use of that feature, it's obvi...

How to initialize a static member

Hi, I want to initialize two static data members. See the two files //Logger.h class Logger{ public: static LoggerConcrete error; static LoggerConcrete write; }; and //Logger.cpp Logger::error = LoggerConcrete(LOG_DEBUG); Logger::write = LoggerConcrete(LOG_DEBUG); The initilization of the two static ...

Why does QWebFrame::evalutateJavaScript do nothing in this case?

I'm calling QWebFrame::evaluateJavaScript in one place in my code and it has no effect. However, if I replace this call with the setTimer(0) call and will call the original function when this timer times out it works. How do I know if it works or not? The JavaScript code which is evaluated in my case calls one JavaScript function which i...

Adobe Dreamweaver Extensions

Does anyone know if its possible to turn off dreamweavers "custom icons" that it shows in the file browser so you can see the standard system-cache ones instead? Something I'm trying to do via an extension but I cant find where its coming from in the large pile of XML files that is dreamweaver. As the guy below pointed out this isn't a...

How to handle different protocol versions transparently in c++?

This is a generic C++ design question. I'm writing an application that uses a client/server model. Right now I'm writing the server-side. Many clients already exist (some written by myself, others by third parties). The problem is that these existing clients all use different protocol versions (there have been 2-3 protocol changes over ...

Troubleshooting Assembly Linker Error, C++, VS 2005

Using Visual Studio 2005 with the latest Service Pack. I have a managed C++ solution with 38 projects (that I've just inherited.) When I build this solution, I'm receiving the following error from the Assembly Linker: "error AL1019: Metadata failure while creating assembly -- The process cannot access the file because it is being us...

How to go about benchmarking a software rasterizer

Ok, ive been developing a software rasterizer for some time now, but have no idea how to go about benchmarking it to see if its actually any good.... i mean say you can render X amount of verts ant Y frames per second, what would be a good way to analyse this data to see if its any good? rather than someone just saying "30 fps with 1 lig...

display map every time it is updated sorted by value

basically, I have the map<std::string, int> so if i have foo 5 bar 10 jack 3 in the map, I want to display it (notice the reverse order) bar 10 foo 5 jack 3 And every time it is updated, I want iterate through all the elements, cout them, sorted by value. What is the good way to implement that? should I provide a comparat...

Can I increment a char* passed to a function?

I'm working on a C++ application that will build a fixed-length record from a set of database fields. I'm writing a function that will accept the output record as a char*, the string to write, and the total length of the field. The purpose of the function is to copy the string to the current position of the char pointer, and then fill th...

How to prevent a function from being optimized

I am optimizing the entire code, yet I dont want a certain function from being optimized, say for debugging purposes. Is there a way to do it on gcc 3.4+ compiler? ...

AV while iterating through hash_map?

_transaction is a private member variable of my class, declared as: public: typedef stdext::hash_map<wchar_t*, MyClass*, ltstr> transaction_hash_map; private: transaction_hash_map _transactions; During cleanup I am trying to iterate through this list and free up any objects still unfreed. However I am getting an AV on the for...