The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Conditional comments

Last post 11-21-2008 8:32 AM by vyznev. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-20-2008 5:32 PM

    • WTFDan
    • Not Ranked
    • Joined on 11-20-2008
    • Posts 2

    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.

     

  • 11-20-2008 6:43 PM In reply to

    Re: Conditional comments

    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.

  • 11-20-2008 6:54 PM In reply to

    • WTFDan
    • Not Ranked
    • Joined on 11-20-2008
    • Posts 2

    Re: Conditional comments

     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"


  • 11-21-2008 5:01 AM In reply to

    Re: Conditional comments

     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.

    Linux is not a code base. Or a distro. Or a kernel. It's an attitude. And it's not about Open Source. It's about a bunch of people who still think vi is a good config UI.

    Notice: Phorm, and its agents including ISPs collecting data on Phorm's behalf, are specifically forbidden from performing any processing or monitoring of the content of the above post. Hence, under the Regulation of Investigatory Powers Act 2000 any such attempt to profile this page by Phorm or its agents is illegal.
  • 11-21-2008 8:32 AM In reply to

    Re: Conditional comments

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

Page 1 of 1 (5 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems