x64 dev questions

Discussion in 'Windows 64bit' started by mysteron, Nov 8, 2005.

  1. mysteron

    mysteron Guest

    i'm trying to figure out what it means to write a pure x64 windows app ..
    and after installing the latest visual studio i'm a little confused about
    the project settings it seems to generate...
    for example:

    I select 'win32 console app' from the wizard, and generate that. Next I go
    to the configuration manager and add a x64 target, based on the settings of
    the x86 (x32?) target I just made.

    Q: looking at the preprocessor I see that _WIN32 is still defined, although
    I would expect it to define _WIN64 ? What is happening here?

    also,

    Q: if i'm writing code that is supposed to compile in 32bit and 64bit,
    irrespective of whether the x64 target is AMD or Itanium), what preprocessor
    define can I look for to detect that i'm compiling 64bit and not 32bit?

    For example, I have code like this:

    #define MYINT int

    and I want to do something like:

    #if defined (_32BIT_COMPILATION)
    #define MYINT int //leave it alone
    #else
    #define MYINT INT64 // use a bigger int on x64
    #endif


    TIA
    mysteron, Nov 8, 2005
    #1
    1. Advertising

  2. Which edition of Visual Studio 2005 are you running, only the Professional
    Edition and up can target 64 bit systems. Standard Editions and below cannot
    compile for 64 bit systems.

    You might want to post this in the following newsgroup to get more
    information and support about targetting appropriate platforms.
    microsoft.public.vstudio.general
    microsoft.public.vstudio.development
    --
    Andre
    Extended64 | http://www.extended64.com
    Blog | http://www.extended64.com/blogs/andre
    http://spaces.msn.com/members/adacosta
    FAQ for MS AntiSpy http://www.geocities.com/marfer_mvp/FAQ_MSantispy.htm

    "mysteron" <> wrote in message
    news:...
    > i'm trying to figure out what it means to write a pure x64 windows app ..
    > and after installing the latest visual studio i'm a little confused about
    > the project settings it seems to generate...
    > for example:
    >
    > I select 'win32 console app' from the wizard, and generate that. Next I go
    > to the configuration manager and add a x64 target, based on the settings
    > of the x86 (x32?) target I just made.
    >
    > Q: looking at the preprocessor I see that _WIN32 is still defined,
    > although I would expect it to define _WIN64 ? What is happening here?
    >
    > also,
    >
    > Q: if i'm writing code that is supposed to compile in 32bit and 64bit,
    > irrespective of whether the x64 target is AMD or Itanium), what
    > preprocessor define can I look for to detect that i'm compiling 64bit and
    > not 32bit?
    >
    > For example, I have code like this:
    >
    > #define MYINT int
    >
    > and I want to do something like:
    >
    > #if defined (_32BIT_COMPILATION)
    > #define MYINT int //leave it alone
    > #else
    > #define MYINT INT64 // use a bigger int on x64
    > #endif
    >
    >
    > TIA
    >
    Andre Da Costa [Extended64], Nov 8, 2005
    #2
    1. Advertising

  3. The 64-bit programming model for Windows 32 is still Win32. In 64-bit mode,
    both _WIN32 and _WIN64 should be defined, and the API is intended to be
    32-bit vs. 64-bit neutral (with some minor fixes made to deprecate 64-bit
    unfriendly things in Win32 in favor of 32-bit vs. 64-bit netural APIs).

    Generally speaking, you should write your code to be 32/64-bit portable
    rather than relying on some specific #define. To make this easier, there
    are a pre-defined set of portability types (DWORD32, DWORD64, DWORD_PTR,
    LONG_PTR, etc.). Use these rather than some home-rolled thing like "MYINT".

    The MSDN website has a lot of stuff on 64-bit programming, as does the
    Platform SDK.

    http://msdn.microsoft.com/visualc/using/building/64bit/default.aspx

    http://msdn.microsoft.com/library/d...us/win64/win64/introducing_64_bit_windows.asp

    --
    Chuck Walbourn
    SDE, Windows Gaming & Graphics

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Chuck Walbourn [MSFT], Nov 8, 2005
    #3
  4. mysteron

    mysteron Guest

    thanks - i already read those links and didn't find much on the questions i
    asked..

    so you say both _WIN32 *and* _WIN64 are defined in an x64 Windows app? Well
    that's not what i'm seeing the wizard generate .. so maybe that's a glitch
    with visual studio? You get WIN32, which seems to imply _WIN32, but no sign
    of _WIN64.. and the cool new intellisense color-coding stuff seems to agree
    that _WIN64 is not defined.
    Try it..
    (I'm using the latest pro version from MSDN subscriber downloads ..)

    ok so i'll define that manually.

    I can see that using the new portability defines for types is a good thing,
    but then doesn't this mean that once I do that, I have to build my 32bit
    code in the 64bit-aware environment(aka VS 2005 pro) ? Because obviously
    these new defines aren't in defined anywhere in the old 32bit headers from
    say VS .NET2003 .. or are they...? Probaly not.. so the rule must be
    something like 'build shared 32/64bit code in the new VS2005pro build
    environment only and use the portablilty types everywhere' .. right?



    "Chuck Walbourn [MSFT]" <> wrote in message
    news:4371203b$...
    > The 64-bit programming model for Windows 32 is still Win32. In 64-bit
    > mode, both _WIN32 and _WIN64 should be defined, and the API is intended to
    > be 32-bit vs. 64-bit neutral (with some minor fixes made to deprecate
    > 64-bit unfriendly things in Win32 in favor of 32-bit vs. 64-bit netural
    > APIs).
    >
    > Generally speaking, you should write your code to be 32/64-bit portable
    > rather than relying on some specific #define. To make this easier, there
    > are a pre-defined set of portability types (DWORD32, DWORD64, DWORD_PTR,
    > LONG_PTR, etc.). Use these rather than some home-rolled thing like
    > "MYINT".
    >
    > The MSDN website has a lot of stuff on 64-bit programming, as does the
    > Platform SDK.
    >
    > http://msdn.microsoft.com/visualc/using/building/64bit/default.aspx
    >
    > http://msdn.microsoft.com/library/d...us/win64/win64/introducing_64_bit_windows.asp
    >
    > --
    > Chuck Walbourn
    > SDE, Windows Gaming & Graphics
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    mysteron, Nov 8, 2005
    #4
  5. mysteron

    mysteron Guest

    sorry - i now see that _WIN64 and _WIN32 are in fact defined, even though in
    the project settings you only see WIN32 and the intellisense displays blocks
    like the following to be greyed out - which is a bit confusing....

    #if defined (_WIN64)
    #pragma message(""_WIN64 is defined!") // this line is greyed out even
    though it is executed at compile time..
    #endif


    "Chuck Walbourn [MSFT]" <> wrote in message
    news:4371203b$...
    > The 64-bit programming model for Windows 32 is still Win32. In 64-bit
    > mode, both _WIN32 and _WIN64 should be defined, and the API is intended to
    > be 32-bit vs. 64-bit neutral (with some minor fixes made to deprecate
    > 64-bit unfriendly things in Win32 in favor of 32-bit vs. 64-bit netural
    > APIs).
    >
    > Generally speaking, you should write your code to be 32/64-bit portable
    > rather than relying on some specific #define. To make this easier, there
    > are a pre-defined set of portability types (DWORD32, DWORD64, DWORD_PTR,
    > LONG_PTR, etc.). Use these rather than some home-rolled thing like
    > "MYINT".
    >
    > The MSDN website has a lot of stuff on 64-bit programming, as does the
    > Platform SDK.
    >
    > http://msdn.microsoft.com/visualc/using/building/64bit/default.aspx
    >
    > http://msdn.microsoft.com/library/d...us/win64/win64/introducing_64_bit_windows.asp
    >
    > --
    > Chuck Walbourn
    > SDE, Windows Gaming & Graphics
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    mysteron, Nov 8, 2005
    #5
  6. They should have made it away where it automatically detects the environment
    its in an and automatically define itself as WIN64.
    --
    Andre
    Extended64 | http://www.extended64.com
    Blog | http://www.extended64.com/blogs/andre
    http://spaces.msn.com/members/adacosta
    FAQ for MS AntiSpy http://www.geocities.com/marfer_mvp/FAQ_MSantispy.htm

    "mysteron" <> wrote in message
    news:...
    > sorry - i now see that _WIN64 and _WIN32 are in fact defined, even though
    > in the project settings you only see WIN32 and the intellisense displays
    > blocks like the following to be greyed out - which is a bit confusing....
    >
    > #if defined (_WIN64)
    > #pragma message(""_WIN64 is defined!") // this line is greyed out even
    > though it is executed at compile time..
    > #endif
    >
    >
    > "Chuck Walbourn [MSFT]" <> wrote in message
    > news:4371203b$...
    >> The 64-bit programming model for Windows 32 is still Win32. In 64-bit
    >> mode, both _WIN32 and _WIN64 should be defined, and the API is intended
    >> to be 32-bit vs. 64-bit neutral (with some minor fixes made to deprecate
    >> 64-bit unfriendly things in Win32 in favor of 32-bit vs. 64-bit netural
    >> APIs).
    >>
    >> Generally speaking, you should write your code to be 32/64-bit portable
    >> rather than relying on some specific #define. To make this easier, there
    >> are a pre-defined set of portability types (DWORD32, DWORD64, DWORD_PTR,
    >> LONG_PTR, etc.). Use these rather than some home-rolled thing like
    >> "MYINT".
    >>
    >> The MSDN website has a lot of stuff on 64-bit programming, as does the
    >> Platform SDK.
    >>
    >> http://msdn.microsoft.com/visualc/using/building/64bit/default.aspx
    >>
    >> http://msdn.microsoft.com/library/d...us/win64/win64/introducing_64_bit_windows.asp
    >>
    >> --
    >> Chuck Walbourn
    >> SDE, Windows Gaming & Graphics
    >>
    >> This posting is provided "AS IS" with no warranties, and confers no
    >> rights.
    >>

    >
    >
    Andre Da Costa [Extended64], Nov 8, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BOK
    Replies:
    0
    Views:
    595
  2. Murali Inguva
    Replies:
    2
    Views:
    451
    Cindy Winegarden
    Dec 3, 2003
  3. CCThai
    Replies:
    1
    Views:
    599
    Saqib
    Nov 22, 2006
  4. Tom

    Dev Component for H323

    Tom, Feb 17, 2006, in forum: VOIP
    Replies:
    1
    Views:
    596
  5. hgruss726
    Replies:
    0
    Views:
    1,213
    hgruss726
    Aug 27, 2006
Loading...

Share This Page