_WINDOWS_ not getting defined

This is a discussion on _WINDOWS_ not getting defined within the Windows Programming forums, part of the Platform Specific Boards category; Hi Guys, I have this piece of code...but somehow even after including windows.h, _WINDOW_ is not getting defines. The below ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    5

    _WINDOWS_ not getting defined

    Hi Guys,
    I have this piece of code...but somehow even after including windows.h, _WINDOW_ is not getting defines.
    The below code compiles just fine ;(

    Code:
    #include <Windows.h>
    #include <iostream>
    using namespace std;
    
    
    int main()
    {
    #ifdef _WINDOWS_
      123
    #endif
      cout << "Hello world" << endl;
      return 0;
    }
    Any help will really be appreciated.

    Thanks

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    SourceForge.net: Operating Systems - predef
    Perhaps because _WINDOWS_ isn't a flag that is set by anybody.
    Where did you get the idea that this symbol was declared?

    The usual test is
    #ifdef _WIN32
    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.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Also that's c++ code... in the C forum.

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    5
    Quote Originally Posted by Salem View Post
    SourceForge.net: Operating Systems - predef
    Perhaps because _WINDOWS_ isn't a flag that is set by anybody.
    Where did you get the idea that this symbol was declared?

    The usual test is
    #ifdef _WIN32
    Well thats the first statement in windows.h file sitting under include directory. Is this the correct file then, getting included from:
    C:\Program Files\Microsoft Visual Studio 8\VC\include\

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    Maybe somewhere else, there is #undef _WINDOWS_ as well.

    _WIN32 is usually pre-declared as a defined symbol by your IDE, so I'd go with that.

    Thread moved to platform specific issues.
    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.

  6. #6
    Registered User
    Join Date
    Oct 2011
    Posts
    5

    Post

    Quote Originally Posted by Salem View Post
    Maybe somewhere else, there is #undef _WINDOWS_ as well.

    _WIN32 is usually pre-declared as a defined symbol by your IDE, so I'd go with that.

    Thread moved to platform specific issues.
    Actually it does gets defined....my problem was that I was including windows.h before stdafx.h on VC.
    Thanks for all the responses...i guess i have many more stupid ones coming

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. where is _ATL_SIMPLEMAPENTRY defined?
    By George2 in forum Windows Programming
    Replies: 0
    Last Post: 04-07-2008, 08:37 AM
  2. PI is #defined in <math.h>, right?
    By dwks in forum C Programming
    Replies: 7
    Last Post: 09-10-2005, 07:45 PM
  3. how to use a self-defined lib in VC6
    By wu7up in forum C Programming
    Replies: 4
    Last Post: 05-12-2003, 03:04 AM
  4. Static but never defined?
    By electrolove in forum C Programming
    Replies: 3
    Last Post: 03-25-2003, 06:11 AM
  5. #if defined...
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 01-06-2002, 07:08 PM

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