The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
Turns out you can't learn Mandarin Chinese by watching television
It is generally accepted that language exposure in the first year of a baby's life is important. To what certainly must be the dismay of couch potatoes everywhere, researchers at the University of Washington determined that it's particularly important that it come from a live human being. Watching DVDs doesn't have any effect. What was particularly notable to the researchers was that even just five hours of exposure made a significant impact.
Const pointers: Logical consequences
Consider this follow-up question to the question from last time: When I call the function, can I assume that the field of the structure will not be modified? If we take a look at the declaration of the function, we see that it reads like this: Go past all the function declaration specification goo and look at the parameter list. It's a pointer to a structure (either ANSI or Unicode, depending on which flavor of the function you're calling). One of the rules for const pointers is that you can read from them but you cannot write to them. Consequently, the function is not allowed to modify the str...
What you don't apologize for is as important as what you do
In the aftermath of the Zidane head-butt incident, there was a lot of speculation over what Materazzi might have said to provoke Zidane's response. Zidane has said he attacked Materazzi because he insulted his mother and sister. Materazzi denied disparaging Zidane's mother. I immediately noticed the very precise denial from Materazzi. (I suspect any parent would recognize the same thing.) And my suspicion was vindicated earlier this week: Italy's Marco Materazzi said he insulted Zinedine Zidane's sister.
You have to free memory with the same allocator that allocated it: Logical consequences
Everybody should know by now that you have to free memory using the same allocator that you used to allocate the memory. If you allocate with then you have to free with ; if you allocate with then you have to free with . Once you've internalized this rule, you can use it to draw other logical conclusions. Consider: When I call the function, who is responsible for freeing the memory that was allocated for the field of the structure? Well, there are two candidates for this responsibility, either the function or the caller of the function. If the function was responsible for freeing the memory, it would ...
In case of fire, go to lunch
Late one morning, the fire alarm went off at work. Everybody dutifully filed out of the building and waited for the all-clear signal. A few of us looked at each other and said, "Let's go to lunch." "I'll drive." "Shotgun!"
You already know what your target architecture is (or at least you should)
Sometimes the questions I see make me shake my head in wonderment. How do I determine programmatically what processor architecture my program was compiled for? I want the x86 version of my program to behave differently from the ia64 version. Is there some API I can call? Note that this person isn't asking whether the program is running on 64-bit Windows. This person wants the program to detect whether it was compiled with an x86 compiler, an ia64 compiler, an amd64 compiler, or whatever. But why do you need an API for this? You already know what your target architecture is because you compiled it yourself...
Just change that 15 to a 1
It would be nice and easy to just change that 15 to a 1. If only it were that simple. In the case described in that article, it's not that a single operation was attempted fifteen times in a loop. Rather, the fifteen operations were scattered all over the program. Suppose, for example, that the network operation was "Get the attributes of this file." The program might be filling in a file listing with several columns, one for the icon, another for the file name, another for the file author, and the last one for the last-modified time. Well, that doesn't access the same file fifteen times. Oh wait, there'...
I think I've just broken the internet
On our internal blogging discussion mailing list, John Kennedy explained that he was trying to set up a video blog but somehow he ended up including the entire video into his RSS feed. He managed to fix the problem, but apologized: If the internet is broken, it was my fault. That was funny enough, but Keith Combs chimed in with some technical advice, and then added, If you manage to break the internet, it won't be the first time.
You're white. Do you want to be in my friend's soap opera?
What does a Mandarin-speaking American woman in Beijing do? If you're Rachel DeWoskin, you serendipitously wind up the star of a daytime Mandarin-language soap opera called Foreign Babes in Beijing, a show that takes all the Western stereotypes (from the Chinese point of view) and milks them for all their melodramatic worth. (They probably watched too much Dallas.)