Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Contact info
 
Other projects
   Altirra

Archives

Blog Archive

"If I were king for a day, and I were making a programming test...."

You've probably seen interview tests for programmers before -- stuff like "how do you reverse a linked list," "why are manhole covers round," and "write strlen()." There are good reasons for such questions, even if they've been asked a thousand times before, and amazingly enough, they're still capable of weeding out candidates.

Most of these questions are sissy programming questions, though. I want a real programming test. One that determines if you have truly spent time in the Win32 trenches. One that weeds out all but the real programmers... and makes the rest of the interviewees sweat and cry Uncle.

(This is probably why I don't write tests for a living.)

I've thrown together some questions I think would challenge an average Win32 programmer. It's probably different from what others might consider "guru" questions, but oh well. How many can you answer? I'll post the answers (well, my answers) next time.

Avery's Win32 Brain Teasers

#1:
Consider the two C++ expressions (x>=y) and !(x<y). Is there a functional difference between them? Why might you choose one over the other?

#2:
Explain the significance of at least three of the following constants:

#3:
When could the following code cause a deadlock?

MessageBox(hwnd, "Hello!", "Test", MB_OK);

#4:
A colleague is receiving the following link error.

linkerr.obj : error LNK2001: unresolved external symbol "public: int __thiscall Foo::GetCurrentTime(void)" (?GetCurrentTime@Foo@@QAEHXZ)
linkerr.exe : fatal error LNK1120: 1 unresolved externals

The method Foo::GetCurrentTime() appears to be both declared and defined correctly as a non-inline method, and other modules in the same project are calling it without problems. Yet, attempting to call it from the module that the colleague is working with results in this link error. Explain a possible reason for the error and a strategy for fixing it.

#5:
Identify the most likely usage for memory pointed to by the following addresses in 32-bit Windows NT (not Win9x/ME):

#6:
Which implementation of a general-purpose memcpy() would be faster for large blocks: one that uses type (char) for memory movement, or one that uses type (double)? Why? You may assume that pointers and sizes are nicely aligned so that boundary fixups are not necessary.

#7:
What is wrong with this implementation of IUnknown::AddRef()? When will it work without any problems, and when will it fail? You may assume that COM aggregation is not involved.

ULONG STDMETHODCALLTYPE Foo::AddRef() {
    return ++mRefCount;
}

#8:
Write a function to return the size of a Win32 GDI bitmap header, given a (const BITMAPINFOHEADER *).

#9:
Describe a reliable, efficient way to wait for a worker thread to exit from a user interface thread, i.e. a thread that has windows.

#10:
Write a function that determines the HMODULE of its own DLL or EXE. Complications: You cannot call GetModuleHandle() or GetModuleHandleEx(), use a cached value, or reference __ImageBase, and the implementation must not be hardcoded to a particular DLL or EXE.

Comments

This blog was originally open for comments when this entry was first posted, but was later closed and then removed due to spam and after a migration away from the original blog software. Unfortunately, it would have been a lot of work to reformat the comments to republish them. The author thanks everyone who posted comments and added to the discussion.