c++

How does _ftime / Windows internal time work?

Hi guys, I have found an interesting issue in windows which allows me to cause the Windows clock (but not the hardware clocks) to run fast - as much as 8 seconds every minute. I am doing some background research to work out how Windows calculates and updates it's internal time (not how it syncs with an NTP servers). Any information anyon...

Do the concepts in Accelerated C++ Practical Programming by Example still hold up today?

I was recommeded a book called: Accelerated C++ Practical Programming by Example by Andrew Koenig and Barbara E. Moo Addison-Wesley, 2000 ISBN 0-201-70353-X The basis of this book is that Object Oriented Programming is highly wasteful memory-wise, and that most source-code should not be written this way, rather that you should use ...

Help finding C++ interval tree algorithm implementation

I'm trying to find an efficient C++ interval tree implementation (mostly likely based on red black trees) without a viral or restrictive license. Any pointers to a clean lightweight standalone implementation? For the use case I have in mind, the set of intervals is known at the outset (there would be say a million) and I want to be able ...

Advantages of Antlr (versus say, lex/yacc/bison)

I've used lex and yacc (more usually bison) in the past for various projects, usually translators (such as a subset of EDIF streamed into an EDA app). Additionally, I've had to support code based on lex/yacc grammars dating back decades. So I know my way around the tools, though I'm no expert. I've seen positive comments about Antlr in ...

Simple C++ UML w/ reverse engineering

I need a way to build C++ code from UML diagrams and vice versa. Should be simple too hopefully. I don't mind paying too much. ...

Simple C++ function -- Is this code "good"?

The following code was produced by a consultant working for my group. I'm not a C++ developer (worked in many languages, though) but would like some independent opinions on the following code. This is in Visual Studio C++ 6.0. I've got a gut reaction (not a good one, obviously), but I'd like some "gut reactions" from seasoned (or even...

C++: Use 'class' or 'typename' for template parameters?

When defining a function template or class template in C++, one can write this: template <class T> ... or one can write this: template <typename T> ... Is there a good reason to prefer one over the other? I accepted the most popular (and interesting) answer, but the real answer seems to be "No, there is no good reason to prefer ...

How to determine whether a Windows application is offscreen?

I am trying to debug a strange issue with users that have LogMeIn installed. After a few days, some of my dialogs that my app opens can end up offscreen. If I could reliable detect that, I could programmatically move the dialogs back where they are visible again. Note: this has to work for multiple monitors and use the win32 API. Howeve...

What are some uses of template template parameters in C++?

I've seen some examples of C++ using template template parameters (that is templates which take templates as parameters) to do policy-based class design. What other uses does this technique have? ...

vswprintf crashes

Hi, using the Symbian S60 5th edition SDK released on October 2nd, I am compiling/running(on sim) the following code snippet: void test(wchar_t *dest, int size, const wchar_t *fmt, ...) { va_list vl; va_start(vl, fmt); vswprintf(dest, size, fmt, vl); va_end(vl); } ... wchar_t str[1024]; // this crashes (2nd string 12...

C++: "std::endl" vs "\n"

Many C++ books contain example code like this... std::cout << "Test line" << std::endl; ...so I've always done that too. But I've seen a lot of code from working developers like this instead: std::cout << "Test line\n"; Is there a technical reason to prefer one over the other, or is it just a matter of coding style? ...

Do c++ static libraries without mfc that are linked to an MFC project throw bad_alloc or CMemoryException*?

I'm working on a large, aging code base for an MFC app. The code has been worked on by many developers over time, and as a result, we have three different ways throughout the code of dealing with the possibility of an allocation failure with new. The first way is to test for NULL on the result of new. We don't use nothrownew.obj so th...

Boost phoenix or lambda library problem: removing elements from a std::vector.

I recently ran into a problem that I thought boost::lambda or boost::phoenix could help be solve, but I was not able to get the syntax right and so I did it another way. What I wanted to do was remove all the elements in "strings" that were less than a certain length and not in another container. This is my first try: std::vector<std::...

ClickOnce: getting MSVCRT C++ DLLs on user's machine

I've been trying desperately to get my application (15 C# dlls and 1 C++/CLI dll with C++ Runtime DLL dependencies) to deploy with ClickOnce. I got it to work by just copying the Release folder, but ClickOnce refuses to copy the files (msvcm80.dll, msvcp80.dll and msvcr80.dll) and deploy them in this folder. I did this nutty workaround ...

Debugging causing exceptions?

I was getting bad data from an application I was writting using C++ in Visual Studio 2k3 so I decided to debug it. Then I found it was throwing an exception but one I can't track down. Then I placed some try/catch blocks and low and behold, when I don't debug there is no exception. That is, I have code that looks like this: std::vecto...

<iostream> vs. <iostream.h> vs. "iostream.h"

When including a header file in C++, what's the difference between... 1) including the .h versus not including the .h when wrapping it in < > signs? #include <iostream> vs. #include <iostream.h> 2) wrapping the header name in double quotes versus wrapping it in < > signs? #include <iostream.h> vs. #include "iostream.h" Thanks in ...

What C++ features do you avoid?

Either due to lack of knowledge, fear, or first-hand experience (getting burned) and saying "You know what, just because it's in the language, you don't have to use it." Quoting Chris Rock: "You can drive a car with your feet, but that doesn't mean it's to be done!" What's the C++ equivalent of driving a car with your feet? ...

Embedding Flash Player in a C++ or Java application?

I would like to embed Flash Player directly inside a C++ or Java application. I found an article that describes how to do this for C#: http://www.adobe.com/devnet/flash/articles/stock_history03.html Unfortunately, I have no experience with C#, COM or ActiveX. I need someone to translate this code to C++, allowing me to embed the Flash ...

Where do I get the ULONG LoginID values to pass to WTSConnectSession?

Where do I get the ULONG LoginID values to pass to WTSConnectSession? I need both a ULONG LogonId and a ULONG TargetLogonId. Is this the same as the SessionID I'll get back from WTSQuerySessionInformation when I pass in WTSSessionId? I suspect not (I tried it and WTSConnectSession did not work.) The MSDN glossay says a logon identifier...

Saving an array of colour data as a PNG file on DS

I'm looking for a library to save an array of colour data to a PNG file. (That's all there is to it, right? I know very little about the internals of a PNG.) This is for use in Nintendo DS development, so something lightweight is preferable. I don't need any other fancy features like rotation, etc. ...