c++

How to link against libxerces-c.so.28?

Whenever we specify -lxerces-c, this looks for libxerces-c.so library in the LIBPATH. Q1. Why are lib files then generated as libxerces-c.so.28? Q2. How should we link against such libraries? The only way I can think of is create a soft link libxerces-c.so which links to the file libxerces-c.so.28. I feel this as an overhead to do. ...

SetLineSpacing() does not work in DirectWrite - why?

I'm rendering text in Direct2D/DirectWrite, but calling SetLineSpacing() on either TextFormat or TextLayout seems to have no effect. Does anyone know why? ...

Making a 2D engine: compiling necessary libraries with the engine instead of the game

I'm making a 2D engine in C++, and I want to be able to supply a .dll and a .lib so that games can just include those and everything is fine and dandy. I've looked at how Ogre does it, and it results in ugliness like this: #ifdef __cplusplus extern "C" { #endif #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 INT WINAPI WinMain( HINSTANCE hIn...

LookupAccountName fails on vista with ERROR_NONE_MAPPED

Hi, I'm trying to call LookupAccountName on Vista - it always fails with the error ERROR_NONE_MAPPED. What could be the reason?? Thanks!! ...

How port WaitForMultipleObjects to Java?

Hello fellows! I have some code in C++ for Windows and I intend to port it to Java. But unfortunately it is not so easy as I thought. Could someone help me, please? Please, take a look at algorithm: HANDLE hExitEvent; HANDLE hDataAvailabeEvent; while(true) { WaitForMultipleObjects(); if (hExitEvent is set) break; if (hDataA...

What is the size of void?

What would this statement yield? void * p = (void*) malloc(sizeof(void)); Edit: An extension to the question. If sizeof(void) yields 1 in GCC compiler, then 1 byte of memory is allocated and the pointer p points to that byte and would p++ be incremented to 0x2346? Suppose p was 0x2345. I am talking about p and not *p. ...

visual indicator (a +-sign) to expand data in Listview (In MFC)

I want to implement a visual indicator (a +-sign) to expand data in Listview (In MFC). This Listview is part of treevew control like there is + sign befor Test, a Array type data, when i will click on + sign it should expand. Before +Test After - |Test[1] |Test[2] |Test[3] |Test[4] |Test[5] |Test[6] |Test[7] ...

Multiple threads and memory

I read in the Visual C++ documentation that it is safe for multiple threads to read from the same object. My question is: how does a X86-64 CPU with multiple cores handle this? Say you have a 1 MB block of memory. Are different threads literally able to read the exact same data at the same time or do cores read one word at a time with ...

Any issues with large numbers of critical sections?

I have a large array of structures, like this: typedef struct { int a; int b; int c; etc... } data_type; data_type data[100000]; I have a bunch of separate threads, each of which will want to make alterations to elements within data[]. I need to make sure that no to threads attempt to access the same data element at t...

C - What does the colon mean in struct declarations ?

Reading the code of TeXmacs, I saw this : struct texmacs_input_rep : concrete_struct { ... }; What does that mean ? This syntax is defined in the C standard , p113, but I didn't find the meaning of it, but that's because I don't know how to read grammar rules. Because concrete_struct is another struct, that contains functions lookin...

How to use extended precision cmath functions by preference

My question is this: is there a way to always use the extended precision versions of mathematical functions - such as sqrt, exp, &c - without using an explicit cast when providing a single or double precision argument? For example I want this functionality, without the hassle of the casting: float x=15.0; float answer; answer=sqrt((l...

Call a JavaScript function from C++

Hello, I have a CDHTMLDialog, with which I have 2 HTML pages and a .js file with a few fairly simple functions. I would like to be able to call one of the JS functions from my program with a simple data type passed with it. e.g. MyFunc(int). Nothing needs to be returned. I would appreciate any guidance on how I go about this, thank...

windows xp localtime daylight savings time problem

My XP system with service pack 2 seems to have transitioned to normal non-daylight time BUT the C++ time routines have not. The Date and Time Properties tool tells me it is now 5:26AM CST BUT localtime() and strftime() think it is 6:26CDT. I have relinked the app and restarted the system since the daylight switch to no avail. If I unc...

__CLASS__ macro in C++

Is there a __CLASS__ macro in C++ which gives the class name similar to __FUNCTION__ macro which gives the function name ...

CWnd::CreateDlgIndirect leaves m_hWnd==NULL

A dialog I'm working on isn't displaying, using: CWnd::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate,CWnd* pParentWnd, HINSTANCE hInst) The call to CreateDlgIndirect is in a lon-used base-class, which effectively takes the IDD of the dialog template in the resource file - it works fine for many other dialogs but I can't see what's...

debugging templates with GDB

Hi all. My gdb is GNU gdb Red Hat Linux (6.3.0.0-1.162.el4rh). And I can't debug templates. Can anybody help me? How can I debug templates with this debugger? Thanks. ...

C++ array list or vector?

Hello, I'm trying to rewrite code I've written in matlab in C++ instead. I have a long cell in matlab containing 256 terms where every term is a 2x2 matrix. In matlab i wrote it like this. xA = cell(1,256); xA{1}=[0 0;3 1]; xA{2}=[0 0;13 1]; xA{3}=[0 0;3 2]; and so on... What would be the easiest thing to use in c++? Can I give ...

How to comment lines automatically in release mode?

I need to have some lines of code "active" in debug mode only, and ignored in release mode. Is there a way to do something like this: #include <iostream> using namespace std; #ifdef _TEST_ #define _cerr cerr #else #define _cerr // cerr #endif int main() { _cerr << "TEST message" << endl; } So that when _TEST_ is not defined, some...

Registering a winform usercontrol as a COM server

I am trying to register a winform user control as a COM Server so my MFC applications can use them. The winform control is written in C++/CLI and uses an unmanaged native dll. I want to make use of .net's terrific Interop services to register this user control as a COM server. [ProgId("MyAx.MyAxControl")] [ClassInterface(ClassInter...

.NET C++. Creating an instance of Form

Hi, I have tried to create a simple app with .NET C++ (I come from C#) but I failed just on the beginning. I have created winforms project and add Form2 to the project. The compiler keeps reporting that Form2 is not a member of my project. What I need to do in order to create an instance of that Form2? Thank you! ...