Thread: inline vrs define

  1. #1
    Registered User
    Join Date
    Jul 2003

    inline vrs define

    just started reading Effective C++ Second Edition by Scott Meyers and I came into a problem with converting the following define
    #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
    I imagine the inline code would be somthing like
    inline bool KeyDown(TYPE vk_code)
       return ((GetAsyncKeyState(vk_code) & 0x8000) ? TRUE : FALSE) 
    What do I use for the type for my parameter (vk_code) being that it is a define?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Use whatever GetAsyncKeyState() uses as the type of its parameter
    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.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Since the return type is "bool" and not "BOOL", you really want to use "true" instead of "TRUE" and "false" instead of "FALSE".
    It gets converted all the same but I like em to match up

    BTW - GetAsyncKeyState() takes an int.


  4. #4
    Registered User
    Join Date
    Jul 2003

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing flags from a DLL?
    By RobotGymnast in forum C++ Programming
    Replies: 17
    Last Post: 10-27-2008, 01:34 PM
  2. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  3. whats wrong here
    By sreetvert83 in forum C++ Programming
    Replies: 15
    Last Post: 09-21-2005, 10:05 AM
  4. LISP (DrScheme) any one?
    By Jeremy G in forum A Brief History of
    Replies: 5
    Last Post: 03-31-2004, 12:52 PM
  5. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM