Thread: Windows Defines - Screwing Stuff Up?

  1. #1
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    New York

    Windows Defines - Screwing Stuff Up?

    I am trying to make some wrappers and stuff, and stuff is being stoopid.

    class wrapper
            example SendMessage( blah, blah blah );
    But, of course, SendMessage is defined as SendMessageA or SendMessageW. I've thought about it for a little, and I'm not sure if this would mess anything up or not. As long as everything is consistent and falls into the wide-char or ansi things consistently across the project, it shouldn't mess things up. I mean, I don't think, should it? Does it even warrant a workaround?

  2. #2
    Join Date
    Jan 2002
    That depends on what you're doing with strings and whether you're #defining UNICODE and _UNICODE. Provided you're consistent, use _T or TEXT macros for string literals and TCHAR arrays or, arguably better since you're coding in c++, typedef, for example a std::basic_string<TCHAR> alias to resolve to std::string or std::wstring depending on the #definition of UNICODE then it shouldn't be an issue.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    I'd say yes, the Windows defines can mess up stuff here. For example, if your header files are clean enough that they don't have their own #include <windows.h>, then you can run into real problems if some code includes the class header after windows.h and some code includes it before, or doesn't include windows.h at all. Suddenly the functions have different names.

    The easiest thing to do, IMO, is follow either a camelCase convention for functions or a K&R convention. In other words, call the thing sendMessage or send_message.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Anyone using Windows 7?
    By Sharke in forum General Discussions
    Replies: 60
    Last Post: 07-12-2009, 08:05 AM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  4. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  5. shutting down windows
    By DavidP in forum A Brief History of
    Replies: 3
    Last Post: 01-02-2002, 12:28 PM