c++

What do the following phrases mean in C++: zero-, default- and value-initialization?

What do the following phrases mean in C++: zero-initialization, default-initialization, and value-initialization? What should a C++ developer know about them? ...

Why was wchar_t invented?

Why is wchar_t needed? How is it superior to short (or __int16 or whatever)? (If it matters: I live in Windows world. I don't know what Linux does to support Unicode.) ...

Direct3D rendering 2D images with "multiply" blending mode and alpha

I'm trying to replicate the Photoshop filter multiply with Direct3D. I've been reading and googling about the different render states and I've got the effect almost working. The problem is that it's ignoring the alpha value of the textures. Here's an image that explains the sitution: http://www.kloonigames.com/petri/stackoverflow_doesn...

Why can't C++ Builder find my headers?

I am required to recompile a C++ builder project, and am come across this problem. one of the unit contains the followings: #include "LMDBaseControl.hpp" #include "LMDBaseGraphicControl.hpp" #include "LMDBaseLabel.hpp" #include "LMDBaseMeter.hpp" #include "LMDControl.hpp" : When I compiled this unit, I got the followi...

How to not discard a CDC path?

I draw some symbols, that belong to certain objects, into a device context and now want to be able to later test if the mouse cursor is above such a symbol. To do this, my plan was to first create a CDC path and use that to create a CRgn region object. pDC->BeginPath(); pDC->Ellipse(ellipse[0], ellipse[1], ellipse[2], ellipse[3]); // C...

how to determine which files has been changed from those in rcs

I am working with a c++ codebase using rcs repository (agh, old I know), during major code changes, I modify a lot of files, which I sometimes lose track of. So I would like to have a small script which will list the files that are different (those that I changed) from files in the repository. It is sort of unrealistic to do rcsdiff on...

SDL GL program terminates immediately

I'm using Dev-C++ 4.9.9.2 (don't ask why) and SDL 1.2.8. Next I've created new project: SDL&GL. This project contains already some code: #include <SDL/SDL.h> #include <gl/gl.h> int main(int argc, char *argv[]){ SDL_Event event; float theta = 0.0f; SDL_Init(SDL_INIT_VIDEO); SDL_SetVideoMode(600, 300, 0, SDL_OPENGL | SD...

PyDateTime_IMPORT macro not initializing PyDateTimeAPI variable

I'm using the Python C API on Windows using Visual Studio 2008. When I attempt to use the PyDate_Check macro, and other related macros, they cause an access violation because the static variable PyDateTimeAPI is null. This variable is initialized using the PyDateTime_IMPORT macro which needs calling before using any date time macros. I d...

Converting wide char string to lowercase in C++

How do I convert a wchar_t string from upper case to lower case in C++? The string contains a mixture of Japanese, Chinese, German and Greek characters. I thought about using towlower... http://msdn.microsoft.com/en-us/library/8h19t214%28VS.80%29.aspx .. but the documentation says that: The case conversion of towlower is locale-...

C++ and Windows , CRT

Hi, I am developing application application using C++ VS 2008. Now I need to either install respective MSM or install redist on customer machine to get this working. Is there any way in which I can just copy those CRT dlls and get the application running. Private assembly option seems to be complicate. ...

Do sequence points prevent code reordering across critical section boundaries?

Suppose that one has some lock based code like the following where mutexes are used to guard against inappropriate concurrent read and write mutex.get() ; // get a lock. T localVar = pSharedMem->v ; // read something pSharedMem->w = blah ; // write something. pSharedMem->z++ ; // read and write something. mutex.release() ; // rel...

Windows: Changing the DLL search order for an Exe

Hi, I have a C++ Exe in an application directory which contains the DLLs used by it. Now, for some testing purpose I need to modify an existing DLL and use that instead of the original one. But in order to not modify the existing installation I cannot backup the existing DLL and replace it with the modified one or move the existing one ...

Modify PL/SQL statement strings in C++

Hello all, This is my use case: Input is a string representing an Oracle PL/SQL statement of arbitray complexity. We may assume it's a single statement (not a script). Now, several bits of this input string have to be rewritten. E.g. table names need to be prefixed, aggregate functions in the selection list that don't use a column ali...

why would std::vector max_size() function return -1?

I have a std::vector<unsigned char> m_vData; m_vData.max_size() always returns -1. why would that happen? ...

OpenCV Grid Area

I want to find the non-white area of an image from a camera using OpenCV. I can already find circles using images from my web cam. I want to make a grid or something so I can determine the percent of the image is not white. Any ideas? ...

C++ Linker Question -- Dynamic and Static library dependency.

I have a Library X that depends on Library Y. I have an App A that calls functions from X. Assume that Library Y is only available as a static library. If both X and Y are statically linked to App A, everything works fine. However, I want X to be a dynamic (shared) library. Currently, having A link Y statically doesn't work as the...

Vector initializing slower than array...why?

I tried 2 things: (pseudo code below) int arr[10000]; for (int i = 0; i < 10000; i++) { for (int j = 0; j < 10000; j++) { arr[j] = j; } } and vector<int> arr(10000); for (int i = 0; i < 10000; i++) { for (int j = 0; j < 10000; j++) { arr[j] = j; } } I ran both the programs and timed it using the "tim...

Does Windows 7 render old programs' controls with GDI or the new DWM/WDDM?

In Windows XP the Win32 API renders the controls using GDI/GDI+. Now I'm on 7, so if I use the API's functions, will the rendering automatically be handled by the DWM/WDDM (so by DirectX)? or will it continue to render with GDI? Or likewise, will an old app written with WinAPI, be rendered with GDI also in Windows 7? Thank you in advan...

What does a C++ compiler do to create an object?

In C code like such: { int i = 5; /* ....... */ } The compiler will replace the code by moving the Stack pointer down (for stacks growing down) by the size of an int, and places the value 5 in that memory place. Similarly, in C++ code, what does the compiler do if an object is created? For example: class b { public : ...

Templates and std::numeric_limits

I have a class called Atomic which is basically an _Atomic_word plus methods that call the gcc atomic builtins. class Atomic{ mutable volatile _Atomic_word value_; public: Atomic(int value = 0): value_(value) {} **** blah blah **** }; I would like std::numeric_limits<Atomic> to instantiate to std::numeric_limits<underly...