Conditional comments



  • Not really a WTF, but still funny.  The C file begins with a long comment block that has a description of the functions it contains:

     

    /

    ....

       Internal Routines:

    ...

     * bar

    #ifdef ENABLE_FOO

     * foo

    #endif

     * baz

    ...

    */

     

    Because, after all, you wouldn't want "foo" to appear in the comments unless it's enabled.

     



  • It just means that foo argument is only present when ENABLE_FOO is #define'd. Subtle hint for those who have a clue. But a function whose arguments change depending on current #defines is not an example of good design.



  •  No, the comment block is listing the functions that are defined in the file.  And yes I understand that there might actually be a use in doing that, but it's still funny to think of it along the lines of telling the user "Well if ENABLE_FOO isn't defined, then block it out of your head that function foo exists."  Kind of like the episode of The Simpsons where Lisa found "Area 51A" and the map plaqard in front of the place had a red dot and said, "You are here.  We are not"




  •  I would expect many documentation tools to obey the #ifdef and only add this section to the file documentation for configurations that have ENABLE_FOO defined. Maybe that is the reason.



  • @WTFDan said:

    /
    ....
     
      Internal Routines:
    ...
     * bar
    #ifdef ENABLE_FOO
     * foo
    #endif
     * baz
    ...
    */
    Wanna bet that's the output of patch -D?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.