Thread: Empty #define

  1. #1
    * noops's Avatar
    Join Date
    Jun 2008
    Posts
    108

    Empty #define

    I did a quick search but did not really find an answer to my concern. In my software I would like to:

    #define INPUT
    #define OUTPUT

    As empty #defines. The purpose is to use them in function definitions to clearly indicate what arguments are meant for input/output. So:

    STATUS Pop(INPUT QUEUE* Queue, OUTPUT NODE* Node);

    The compiler did not complain but I am curious if there are any caveats I should be aware of.

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    INPUT and OUTPUT aren't very unique phrases for a define, and I don't see how this helps programmers any more than a comment would.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Arguably, a better place would be in the comment (especially if you use say Doxygen).
    A comment would actually tell you what it did, and what to expect.
    Code:
    /**
     * Pop - removes an element from the near end of the queue
     * [in] Queue - the queue
     * [out] Node - the result
     */
    STATUS Pop(INPUT QUEUE* Queue, OUTPUT NODE* Node);
    Being "compiled", they're subject to all sorts of namespace issues. Being awfully generic names, you could have problems if you have to integrate with some other package which really uses those symbols for something completely different.

    Of the people who use this technique, there's no standard naming convention which might prove useful.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling error: Too many arguments.
    By Tuah in forum C++ Programming
    Replies: 16
    Last Post: 06-10-2008, 04:28 PM
  2. C problem with legacy code
    By andy_baptiste in forum C Programming
    Replies: 4
    Last Post: 05-19-2008, 06:14 AM
  3. Accessing syscalls from C
    By lilcoder in forum C Programming
    Replies: 17
    Last Post: 09-19-2007, 02:27 PM
  4. C Programming 2d Array Question
    By jeev2005 in forum C Programming
    Replies: 3
    Last Post: 04-26-2006, 03:18 PM
  5. whats wrong here
    By sreetvert83 in forum C++ Programming
    Replies: 15
    Last Post: 09-21-2005, 10:05 AM