Empty #define

This is a discussion on Empty #define within the C Programming forums, part of the General Programming Boards category; I did a quick search but did not really find an answer to my concern. In my software I would ...

  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
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,761
    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
    32,823
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 05:28 PM
  2. C problem with legacy code
    By andy_baptiste in forum C Programming
    Replies: 4
    Last Post: 05-19-2008, 07:14 AM
  3. Accessing syscalls from C
    By lilcoder in forum C Programming
    Replies: 17
    Last Post: 09-19-2007, 03:27 PM
  4. C Programming 2d Array Question
    By jeev2005 in forum C Programming
    Replies: 3
    Last Post: 04-26-2006, 04:18 PM
  5. whats wrong here
    By sreetvert83 in forum C++ Programming
    Replies: 15
    Last Post: 09-21-2005, 11:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21