This blog considered illegal (13 Apr 2008)

If you are a C++ programmer, my blog should give you the creeps. Sometimes because of what I write here, I guess - but definitely because of its name. You are not alone. The first time someone told me about that "#define private public" line which he had just found in our codebase, I didn't want to believe that someone actually did that.

But it was oh so true.

If I remember correctly, there was a reason for it - certainly not a good one, but a reason: Some experimental test code needed to access a class member which was declared private, and the author of that code wasn't supposed to change the class under test, or did not have access to it.

This disgusting hack was probably meant as a stopgap solution, but then remained in the code for way too much time - until it was re-discovered and became a part of our local programming folklore. I was actually grateful for this hack - without it, I'd probably still be searching for a name for my blog!

And then, just a few days ago, I came across the following excerpt from the standard for the C++ standard library (ISO/IEC 14882:1998(E), section 17.4.3.1.1):

A translation unit that includes a header shall not contain any macros that define names declared or defined in that header. Nor shall such a translation unit define macros for names lexically identical to keywords.

Good heavens, my blog is cursed upon by the standard! Expelled will I be from the C++ community! Never will I be on a first-name basis with Mr. Stroustrup! What have I done...


Previous month: Click here.
to top


You are here: Blog > DefinePrivatePublic200804

r1.4 - 03 May 2008 - 14:46 - ClausBrod to top

Blog
This site
RSS

  2016: 10 - 7 - 3
  2015: 11 - 10 - 9 - 4 - 1
  2014: 5
  2013: 9 - 8 - 7 - 6 - 5
  2012: 2 - 10
  2011: 1 - 8 - 9 - 10 - 12
  2010: 11 - 10 - 9 - 4
  2009: 11 - 9 - 8 - 7 -
     6 - 5 - 4 - 3
  2008: 5 - 4 - 3 - 1
  2007: 12 - 8 - 7 - 6 -
     5 - 4 - 3 - 1
  2006: 4 - 3 - 2 - 1
  2005: 12 - 6 - 5 - 4
  2004: 12 - 11 - 10
  C++
  CoCreate Modeling
  COM & .NET
  Java
  Mac
  Lisp
  OpenSource
  Scripting
  Windows
  Stuff
Changes
Index
Search
Maintenance
Impressum
Home



Jump:

Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback