Many Bazel attributes support the use of predefined variables
and functions such as @D
for output directory or
$(location //foo:bar)
to get the path to a label. But what
if you want to apply some sort of tranformation to these
variables, or define your own custom make variables? This
blog post explains how.
C
Let’s say you are using Bazel to build a C program which links against a system-provided version of libcurl, the multiprotocol file transfer library. What is the best way to link your program against this library within Bazel? This blog post provides an answer to that question.
Read more...In the Windows XP login screen, the password text box will warn you with a balloon tooltip if you accidentally turn Caps Lock on. The balloon tooltip appears to be a Windows tooltip common control with the TTS_BALLOON
style.
To replicate this functionality, I decided to write a function called ShowMsgBalloon()
which, given a control and the various balloon tooltip parameters, creates and shows the balloon tooltip below the control.
Like many common controls, the tooltip control supports custom drawing for maximum flexibility. This is a quick tutorial on how to use the tooltip custom draw facility.
First, start with the following scratch program (which is a slightly modified version of Raymond Chen’s scratch program):
|
|
Next, we’ll add a tooltip to this window. We’re not going to do anything fancy like tooltip multiplexing so we’ll use TTF_SUBCLASS
.
Windows C++ developers remain all too familiar with the standard Windows crash dialog. This post is an attempt to teach developers how to understand the data the crash dialog reports to diagnose difficult issues. A basic understanding of assembly language is assumed; for more background on these topics please read Matt Pietrek’s “Under The Hood” articles in the Microsoft Systems Journal February 1998 and June 1998 issues.
To begin with, let’s write an application that crashes with a null pointer dereference:
Read more...Avoid atoi()
and related functions: they do not distinguish between invalid input and a valid “0″ string. Use functions which properly report errors, such as strtod()
.
On some Windows operating systems (primarily Windows 95, 98, and ME), GetOpenFileName()
and GetSaveFileName()
(and wrappers of these functions such as MFC’s CFileDialog
) will permanently change the process’s current working directory unless the OFN_NOCHANGEDIR
option is specified. As you can imagine, this can easily break your application if you ever rely on the current working directory being set to a particular value (such as if you open files using relative paths).
Of course, it is best to eliminate any such current working directory assumptions from your application completely.
Read more...Consider the following piece of code (adapted from a real-world bug):
|
|
This function will work most of the time, but every now and again it will run across a directory which it will claim isn’t one. Why?
Read more...At work I recently was given the task to support gzip-based HTTP response compression in a C++ MFC application. For a while I was convinced that there was no way to support in-memory decompression of gzip-compressed data using zlib, and so I wrote the gzipped data to a temporary file and then used the gzopen()
/gzread()
-family of functions in zlib to read it back (as described in the zlib manual).
I spent a lot of time looking at the zlib code to try to see why the in-memory streaming decompression function inflate()
wasn’t working for gzip-compressed data and determined that zlib wasn’t recognizing the gzip headers. The inflate()
function had code which purported to understand the headers, but it wasn’t being enabled due to reasons unknown. After some more sleuthing, I noticed the gzopen()
/gzread()
functions implemented their own gzip header detection and passed only the raw data to inflate()
. Once I noticed this, I threw my hands up in disgust and said it couldn’t be done.