Windows GUI Preprocessing

This is a discussion on Windows GUI Preprocessing within the Windows Programming forums, part of the Platform Specific Boards category; How, using the proprocessor, can I find out if a program is being compiled as a Windows GUI Program? I ...

  1. #1
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256

    Windows GUI Preprocessing

    How, using the proprocessor, can I find out if a program is being compiled as a Windows GUI Program? I have a set of headers that I use, and a couple of them deal with Windows GUI programs specifically. How would I be able to prevent their code from being included, if the program is just a normal Console application? If this is compiler specific, I'm interested in info for all compilers that you know of. Thanks.
    Code:
    void function(void)
     {
      function();
     }

  2. #2
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Ahh. Change GUI to API. My bad.
    Code:
    void function(void)
     {
      function();
     }

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    25
    Well, here are the first lines of my <windows.h> header: (I'm using Visual Studio 2003, but that shouldn't matter, as Microsoft = backwards compatibility :-))

    Code:
    #ifndef _WINDOWS_
    #define _WINDOWS_
    
    
    #ifndef WINVER
    #define WINVER 0x0501
    #else
    #if defined(_WIN32_WINNT) && (WINVER < 0x0400) && (_WIN32_WINNT > 0x0400)
    #error WINVER setting conflicts with _WIN32_WINNT setting
    #endif
    #endif
    
    #ifndef _INC_WINDOWS
    #define _INC_WINDOWS
    So, as I see, you can #ifdef-test either of the _WINDOWS_, WINVER or _INC_WINDOWS definitions.

  4. #4
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    I've already looked into windows.h, winver.h, winnt.h, etc. All the definitions I found were either defined or not defined by the compiler and did not change, regardless of whether I was compiling as an API or as a console. And all of those are defined by the actualy header. I'm looking for something defined by the compiler, only when you're compiling as an API application.
    Code:
    void function(void)
     {
      function();
     }

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,670
    There's nothing standard for detecting this at compile time. The only close is the VisualStudio practice of using "_CONSOLE" for console applications and "_WINDOWS" for non-console applications. These aren't even used by the MS headers. It's just a VisualStudio thing.

    Why do you need to distinguish between the two at compile time? Who cares if some GUI headers get included with a console app.

    gg

  6. #6
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    It doesn't really matter, no. I just thought it was possible. If it isn't, ahh well. Thanks for helping.
    Code:
    void function(void)
     {
      function();
     }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ gui for windows where to start
    By prixone in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2006, 10:48 PM
  2. Help Needed With Windows GUI
    By edselman in forum Windows Programming
    Replies: 5
    Last Post: 08-22-2002, 09:38 PM
  3. Linux's GUI slower than windows'....
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 02-16-2002, 07:47 PM
  4. GUI Programming :: C++ Exclusive
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 01-25-2002, 02:22 PM
  5. C++: Reference Book, GUI, Networking & Beyond
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 11-10-2001, 07:03 PM

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