The printf family of functions take a format string, containing both regular text and special formatting specifiers, and at least as many additional arguments as there are formatting specifiers in the format string. Each formatting specifier is supposed to indicate the type of the corresponding argument. Then, via compiler-specific magic, that argument value is accessed and formatted as directed.
C originally only had char, short, int, and long integer types (in signed and unsigned versions). So the original set of format specifiers only supported interpreting arguments as one of those types.
With the rise of <stdint.h>, it’s common to want to print a uint32_t, or an int64_t, or similar. But if you don’t know what type uint32_t is, how do you know what format specifier to use? C99 defines macros in <inttypes.h> that expand to suitable format specifiers. For example, if uint32_t is actually unsigned long, then the PRIu32 macro might be defined as "lu".
uint32_t u = 3141592654;
printf("u: %" PRIu32 "\n", u);
Unfortunately <inttypes.h> isn’t available everywhere. So for now, we have to reimplement it ourselves. The new mfbt header mfbt/IntegerPrintfMacros.h, available via #include "mozilla/IntegerPrintfMacros.h", provides all the PRI* macros exposed by <inttypes.h>: by delegating to that header when present, and by reimplementing it when not. Go use it. (Note that all Mozilla code has __STDC_LIMIT_MACROS, __STDC_FORMAT_MACROS, and __STDC_CONST_MACROS defined, so you don’t need to do anything special to get the macros — just #include "mozilla/IntegerPrintfMacros.h".)
The implementations of <inttypes.h> in all the various standard libraries/compilers we care about don’t always provide definitions of these macros that are free of format string warnings. This is, of course, inconceivable. We can reimplement the header as needed to fix these problems, but it seemed best to avoid that til someone really, really cared.
<inttypes.h> also defines format specifiers for fixed-width integers, for use with the scanf family of functions that read a number from a string. IntegerPrintfMacros.hdoes not provide these macros. (At least, not everywhere. You are not granted any license to use them if they happen to be incidentally provided.) First, it’s actually impossible to implement the entire interface for the Microsoft C runtime library. (For example: no specifier will write a number into an unsigned char*; this is necessary to implement SCNu8.) Second, sscanf is a dangerous function, because if the number in the input string doesn’t fit in the target location, anything (undefined behavior, that is) can happen.
sscanf("256", "%" SCNu8, &u); // I just ate ALL YOUR COOKIES
IntegerPrintfMacros.h does implement imaxabs, imaxdiv, strtoimax, strtoumax, wcstoimax, and wcstoumax. I mention this only for completeness: I doubt any Mozilla code needs these.
This is part ten of a series of posts discussing various aspects of a bike trip I did across the United States in 2012. Part one discussed the start of the trip and choosing a route. Part two discussed my daily routine and nightly shelter. Part three discussed general mileage, elevation encountered, and state-by-state scenery. Part four discussed mileage extremes and water. Part five discussed food. Part six discussed elevation extremes, particularly crossing the Continental Divide at Monarch Pass. Part seven discussed how I used down time and how I kept electronics charged. Part eight discussed mechanical problems and other surprises. Part nine discussed health on an aggressively-paced cross-country bike trip. This post discusses how I managed to get home afterward.
Arranging the flight
I put off buying a plane ticket home for approximately as long as I could, to afford myself the most flexibility in returning. I had a firm deadline of August 23 (or maybe the morning of August 24, but that would really be pushing it) to finish, because some friends were getting married in Golden Gate Park on August 25, and I didn’t intend to miss it. (This would cut it close timing-wise, but as long as I knew sufficiently far in advance, it seemed doable.) If by some chance I finished early, it might be worth biking to some particular airport to fly from there. If by some even less likelier chance I didn’t finish, I would need to fly from whichever airport happened to be closest.
On Monday, August 20, I found myself by a library, before lunchtime (so with considerable time left in the day to bike) with ~420mi to go in 3.5 days. With the end comfortably in sight, it seemed safe to book a flight. Yorktown’s poorly situated for getting to any major airport, so I’d have some fun leaving it. But unlike excess distance between me and Yorktown, this problem could be relatively simply solved with a large infusion of cash. So I didn’t sweat arranging a return flight before then, and I booked a flight from Norfolk to San Jose (with only a single stop along the way) on Southwest, leaving mid-afternoon August 24. The cheap tickets were all gone by then, of course, but my fare did get me a drink coupon on each leg as a consolation bonus.
I arrived in Yorktown just before 19:00 on August 23, giving plenty of time to get a bite to eat and clean up to head out the next day. I called one bike shop in town to ask about packing up my bike the next day for travel (justifiably oversized luggage, but a bargain at ~$50 with Southwest). They didn’t know if they had any boxes of the right size in stock, so I decided next morning to head to the other nearby bike shop instead.
The next morning I packed up my stuff and hopped on my bike one last time to head to the Yorktown park headquarters, as an easily-found location for a taxi. (I could have biked to Norfolk, but not easily in time for a flight. Plus I’d still need to get my bike packed up and I’d need a shower.) Yorktown’s way at the edge of the Norfolk taxi coverage — it took just under half an hour for the taxi to even get to me. The next stop would be the other local bike shop. On the way I mentioned my plans — to wait for the bike to be packed up, then to head to Norfolk and the airport. This worked out pretty well, because the driver noted that I was still pretty far away from taxis, so it’d be fastest to just call her again. I pocketed a business card to make the call when the bike was packed up.
On talking to the bike shop folks, I realized I had a slight problem. The bike shop would be perfectly happy to box up my bike for me, but they couldn’t do it today: they were already booked as far as work went. Hmm. They did have a spare box and tools, if I wanted to pack up the bike myself. But I was slightly pressed for time, on vacation, and not particularly interested in packing my bike myself. As it happened, however, the bike shop I’d called the previous day (that wasn’t sure if it had any boxes of the right size in stock) didn’t have a box but did have time to pack a bike. By our powers combined, I could take the bike box here to the other bike shop, and I could get my bike packed up there. Win!
So I called the taxi again, we took the box to the other bike shop, I had them pack it up, then I headed to the airport and my flight. The timing was close but not razor-thin, and I had something like half an hour’s wait at the airport before my flight was scheduled to board. (It’s a good thing I booked the last flight of the day heading west! But it seemed foolish booking any of the earlier ones, given that I’d have to travel forty miles from Yorktown to Norfolk and deal with the bike along the way.) I got a few funny looks at airport security when I sent my shoes through the scanner: metal cleats in the soles will do that. A couple flights and a bunch of reading later, I was in San Jose, only a short ride (not on the bike, from a friend ) from home.
Hindsight is 20/20
Looking back it’s obvious what I should have done for that last day: I should have called a couple weeks or so in advance, told them my plans, and had them clear a spot to pack a bike when I arrived. Some part of me unconsciously resisted doing this because of the uncertainty of my travel plans, I’m sure. But it seems unlikely it would have been a problem to call, make that uncertainty clear, and then give a call a couple days out with the go/no-go signal as needed. But in the end, it all basically worked out. And even if it hadn’t, these were problems that — again — could be solved, if absolutely necessary, with a large infusion of cash. As a true last resort, I’m sure I could have found someone to pack and ship the bike for me, while I flew back home separately. It would have been more than a bit inconvenient and more than a bit expensive (I’d guess at least $100 more, but that’s just a guess), so I’m glad I didn’t have to do it. But it would have been doable, if I had to.
Naming and faming
It took a fair bit of composed scrambling (I was reasonably composed, tho I’m sure others would have freaked out ) to make all the connections that last day. BikeBeat was the bike shop that couldn’t box my bike up but could provide a bike box; a different BikeBeat happened to be the ones that suggested the previous day that I could probably bike to Yorktown with two broken spokes (and that gave me a number to call if I broke a third en route). Back Alley Bikes was the bike shop that could box my bike while I waited but couldn’t provide a bike box. And last but not least, Karen (1-757-503-0657) shuttled me around to the different bike shops and then to the airport, going out of her way (literally, to Yorktown ) to do so. (And when it came time to swipe a card and pay with Square — she informed me she was one of, if not the, first drivers at the cab company to accept credit cards, that way — I didn’t even hesitate to pick the 35% tip option. Totally justified, totally worth it.)
This is part nine of a series of posts discussing various aspects of a bike trip I did across the United States in 2012. Part one discussed the start of the trip and choosing a route. Part two discussed my daily routine and nightly shelter. Part three discussed general mileage, elevation encountered, and state-by-state scenery. Part four discussed mileage extremes and water. Part five discussed food. Part six discussed elevation extremes, particularly crossing the Continental Divide at Monarch Pass. Part seven discussed how I used down time and how I kept electronics charged. Part eight discussed mechanical problems and other surprises. This post discusses health issues I had along the way.
It’s one thing to bike a hundred miles in a day, once. It’s another to do it several days in a row, as I’ve done several times on the DALMAC ride in Michigan (80-100mi/day for four or five days, on the routes I’ve taken). In a certain sense, it really isn’t that different to bike a hundred miles a day (average) for over a month. It is a bit different, however, when that month includes no true, complete rest days. Without rest days, you give your body almost no time to heal before it’s back on again for another day of beating.
I could feel, as I traveled, that I was always slightly on the edge of exhaustion. I didn’t get a cold, but I could tell I was always on the very edge of one: slightly out of breath all the time, with a slight cough that never really went away, slightly weary every morning as I woke up to prepare for yet another long day of riding. I’m actually somewhat surprised I didn’t get one, from the constant strain I was putting on my immune system.
Beyond simple exhaustion, my pace and timing forced certain health sacrifices on me, that being able to truly rest might have healed quicker.
At some point on the first day, I pedaled slightly too aggressively, quickly, or eagerly with my right leg, and I slightly pulled a back lower-leg (ankle?) muscle. This didn’t prevent me from cycling, but it did make it slightly painful to push hard while pedaling with that leg: I cycled for about a week with my right toes pointed downward further than I might ordinarily do, so that I wouldn’t stress it. Interestingly, as soon as it healed, I experienced the same slight injury to my left leg, and it too was slightly out of sorts for a week. Neither injury materially interfered with cycling, and both were only barely noticeable while walking. But a day off might have healed these injuries, rather than having to live with them for a week each of cycling, if I’d been able to take one. (Or it might have taken several days regardless, for all I know.)
Left knee pain
The other pain I experienced, that I’m still at somewhat of a loss to explain, was in the muscle just above my knee, on the front inside. It first arose on the third day as I climbed from Folsom Lake into the Sierras, subsided overnight, then returned again the next day up and over Carson Pass. The pain was much of the reason my third day was comparatively short and slow. The other side of the Sierras, I stopped at a bike shop to ask if they had any ideas what might be causing the pain. (I, er, carefully didn’t mention the bike was only four days old, figuring if there was a problem, it should be visible and observable regardless. Not that I was afraid of looking stupid or anything, of course.) Their only thought was my left cleat was misaligned, but I hadn’t touched that cleat in over a year, so it seemed pretty unlikely. But the pain appeared to correlate with ascending, and Nevada promised to be flatter, so they suggested continuing on and seeing what happened. And indeed, the pain disappeared — all the way til Virginia. Then I felt it almost returning, at lesser intensity, by the latter phases of each day.
My initial thought was that the pain was some early-trip lack of strength which subsided after some toughening up. But that wouldn’t explain its reappearance at the end of the trip. (I dealt with it at end by trying to bike slightly easier and by wearing my slightly-compressing leg warmers. A doctor would of course have recommended rest, but that Wasn’t Going To Happen, so I did the best I could in its absence.) Even now I’m still not sure what might have caused it. Perhaps, even given a year at that position, the cleat still needed adjustment when subjected to particularly harsh climbing? *shrug*
(Hmm, seems I forgot August 31 was a day when scheduling these posts. Subsequent posts will return to the one-a-day schedule.)
This is part eight of a series of posts discussing various aspects of a bike trip I did across the United States in 2012. Part one discussed the start of the trip and choosing a route. Part two discussed my daily routine and nightly shelter. Part three discussed general mileage, elevation encountered, and state-by-state scenery. Part four discussed mileage extremes and water. Part five discussed food. Part six discussed elevation extremes, particularly crossing the Continental Divide at Monarch Pass. Part seven discussed how I used down time and how I kept electronics charged. This post discusses mechanical issues and other surprises.
Tires and tubes
I replaced five bike inner tubes over the entire trip, and I replaced one tire about 750mi in after a catastrophic flat. After I returned I talked to someone who’d done a different cross-country route who’d had closer to a dozen flats. I’d have expected closer to a dozen flats than five for the trip, and no catastrophic flat (although I wouldn’t have been surprised to wear out a tire). As I carried two spare tubs and one spare tire, none of these mishaps presented any real issue. (Although after the catastrophic flat, I did just barely make it into the bike shop in the next town for a new backup tire and spare tube, before it closed for the day.)
I anticipated possibly having to deal with broken spokes at some point or another, so I carried a round of replacements: one front, one back. Properly truing spokes is a black art, but I could probably fake it til I made it to a bike shop. The first time I broke a spoke, I heard a metallic snap but didn’t recognize it as a broken spoke. I only learned about it a couple hours later when the bike shop in Pueblo asked if I wanted it fixed. (Good timing on my part!)
The second broken spoke happened about twenty-five miles from the end of the trip — and it was actually two rear spokes. I didn’t have that many replacements, and I also, er, discovered I didn’t have the tools to remove the rear cassette to replace even one of them. (*whistles innocently* There aren’t many road-ready tools for doing this, actually, as cassette removal on the go is a very uncommon thing to have to do. These suggestions are about what I’m aware of now, but with no big trips planned, I’m not in a huge rush to pick one.) Beyond that, tho, I’d been told at a shop in Kansas that I really needed a new rear wheel. (They didn’t have any, but they said their jury-rigged fix might last til the end of the trip.) So ideally I didn’t want to install new spokes for only twenty-five miles. I removed the broken spokes and gingerly biked to a bike shop in Williamsburg, where I asked about just finishing the trip without them. The bike shop thought it could work if no more spokes broke, handed me a business card with phone number just in case, and advised me to avoid bumps and potholes. This was a slightly frazzled way to end the trip, a couple hours later than expected, but it worked out.
I knew, entering the trip, that I would be traveling very light. I would be (heh) on a non-touring bike; my seatpost rack limited me to 25 pounds in panniers; and I wouldn’t carry much on my back except water, repair tools, and sundries. I could do this because I’m comfortable traveling light as a backpacker. Doubtless many cyclists are backpackers, but I expected to be at the lighter end of the crowd. I did not expect to be the lightest. Every other long-distance cyclist I saw was on an apparently heavier bike with both front and rear panniers. I expected to see a cyclist or two touring with rear panniers (possibly even less in more-populated areas). I saw none. I don’t know how to explain this.
Locking up the bike
In normal life I carry a bike U-lock with me everywhere I go, locking up my bike whenever I have to leave it. I did the same on this trip, expecting I’d often leave it unattended while in stores and the like. In practice I did this, but as my route traveled through mostly lightly-populated areas, I only used it once, during a ninety-minute stop at a library in Kansas. (I didn’t lock it while in campgrounds, and in hotels I kept it with me in my room.) I’ve read stories of others biking across the country who’ve had bikes stolen, so it is a danger. Yet given what I saw and experienced, I’d consider leaving it behind were I to do this ride again.
I despise phones in general and cell phones in particular. But for this trip, it seemed important to have one to be able to call ahead to arrange lodging as I traveled. So I set up a one-month prepaid plan with T-Mobile, to renew at the end of the month. This was actually a huge mistake, as I quickly learned that T-Mobile’s coverage outside metro areas is very sparse. (Data especially, but even call service was often light to non-existent.) In the west I was told by various people that Verizon or AT&T would work well in different places, and in the east apparently both worked equally well. It happens that T-Mobile’s being primarily an urban network is common knowledge to anyone in Silicon Valley with a cell phone. But that doesn’t include me, so I got to learn something.
As my data plan frequently didn’t work, or worked poorly, I used numerous apps with little data access. I was surprised how poorly many apps worked. Navigating through screens that downloaded data often didn’t cache that data: going forward and backward might require reloading just-viewed data. Goodreads was the biggest offender in this regard. Mobile developers: offline performance matters! Don’t sell it short just because you live in a San Francisco world of ubiquitous, high-quality, high-speed data. Vast swaths of the country are entirely unlike San Francisco in this regard.
This is part seven of a series of posts discussing various aspects of a bike trip I did across the United States in 2012. Part one discussed the start of the trip and choosing a route. Part two discussed my daily routine and nightly shelter. Part three discussed general mileage, elevation encountered, and state-by-state scenery. Part four discussed mileage extremes and water. Part five discussed food. Part six discussed elevation extremes, particularly crossing the Continental Divide at Monarch Pass. This post discusses what I did when I was off my bike each day, and how I kept various electronics charged.
Reading during down time
I biked seven to nine hours a day most days, but as long as I roughly kept moving, I’d have down time each day beyond what I’d need for eating and sleeping. With space and weight at a premium, the obvious answer was an ebook reader. So I finally went and got a Kindle: a touch version with 3G, as I expected I might often be places without wifi. I definitely put it to good use, reading these books while gone:
Around the World in Eighty Days (on the flights home — particularly excellent in the context of having just finished an adventure of a trip; the headiness conveyed by the book worked extremely well in that situation)
The Kindle worked extremely well as entertainment: minimal weight and volume, a very wide selection, and (via a case with built-in light) amenable to use anywhere, including inside a tent in darkness. I’d often pull it out over lunch and do some reading while eating, and a handful of times I stopped mid-day and sat and read for awhile. But most of my reading happened just before I went to sleep. I carried headphones and listened to music previously loaded on the Kindle as I read, sometimes. Amazon wasn’t kidding when they called it “experimental”: not even the slightest bit of control over the organization of music, just a single linear playlist based entirely on file creation times. It was adequate, but it certainly wasn’t fully satisfactory.
One issue presented by reading on a Kindle, and by a phone, and by a rechargeable-battery-powered head light with ~3h life (depending on mode), and by a camera with rechargeable battery, was a constant need for power outlets to recharge everything. I barely used (and shouldn’t have brought) the camera, so charging that was never an issue. The others I plugged in every chance I got at the end of the day.
The light needed recharging most often, depending on my recent evening cycling hours. Generally, however, I didn’t bike too long after dark, so the head light never ran too low on me. (I did have two consecutive days with night riding in Kansas where I ran it down to near-empty the second night, and I had a weak backup light ready for use when needed. But I timed it near-perfectly to arrive probably 15-30 minutes before my main light ran out of battery, so I never used the backup, except as a makeshift flashlight when camping.)
I used the phone, plugged in, as an alarm clock when I stayed in motels. (I used my watch for this when camping, due to battery concerns.) Except when plugged in, I turned the phone on only to take pictures or make calls, so its battery didn’t require particular recharging diligence.
The Kindle, of course, required the least recharging effort. Its non-power-drawing screen, and my turning off wireless use, let it do fine with only an occasional recharge. (Although I’m sure the light in the case compensated to some extent for its low power consumption.)
Had I used a GPS unit, I’d have had to plug that in as well, and I’d have needed to charge it more often than I needed to charge anything else I carried. Charging everything else was a minor hassle; I’m glad I didn’t have to deal with the same thing for a GPS unit too. (Although, to be fair, maps have their own problems. In addition to requiring a modicum of effort to not have to carry all ten maps for the full route the entire way, I lost one map out the back pocket of my cycling jersey one day, resulting in an uncomfortable day or so until I found a replacement.)