Since the subject of building codes as they relate to home inspections came up here recently, I thought the article below would be useful. It's written by a local home inspector (SF Bay Area, East Bay region), and contains his observations about the inspector's responsibilities and discretions related to building codes. Good stuff.
formatting link
(Sorry, it's a PDF; his article starts on page 2.)