Update code for Vista 64

This is a discussion on Update code for Vista 64 within the C++ Programming forums, part of the General Programming Boards category; What would I need to change in this program to get it working on a Windows Vista 64 (AMD). http://www2.hawaii.edu/~qzhang/FileSystemWatcher.html ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    41

    Update code for Vista 64

    What would I need to change in this program to get it working on a Windows Vista 64 (AMD).

    http://www2.hawaii.edu/~qzhang/FileSystemWatcher.html

    I assume most changes would be in the stdafx.h (except changing the target machine for the project to: "MachineX64 (/MACHINE:X64)"

    The stdafx.h looks like this:

    <snip>
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //

    #pragma once

    // Modify the following defines if you have to target a platform prior to the ones specified below.
    // Refer to MSDN for the latest info on corresponding values for different platforms.
    #ifndef WINVER // Allow use of features specific to Windows XP or later.
    #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
    #endif

    #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
    #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
    #endif

    #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
    #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
    #endif

    #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
    #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
    #endif

    #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
    // Windows Header Files:
    #include <windows.h>


    </snip>

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Without a detailed study of the code (and I suspect, without even following the link) that it is more than a dozen or so lines, it would be impossible to say if there's anything in there that breaks 32 to 64-bit compatibility.

    My approach would be to first compile it with X64 architecture. If that throws errors or warnings[1], fix them.
    If the compile is complete without errors and warnings, then proceed to run the code.
    If the code runs, job done. If it's doesn't run, then it's a case of figuring out why - which may be trivial or difficult, depending on what it actually does.


    [1] Obviously, some code throws warnings when compiled normally - if the code compiled for 32-bit throws warnings, please try to understand what those are, and pay close attention to NEW warnings when compiling for 64-bit. There are specific warnings about assigning pointers to 32-bit integers in Visual Studio C++ - these are PARTICULARLY important to pay attention to, as they will BREAK when you move to 64-bit.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    41
    Well, it's actually not that much code. It's just one class with mostly JNI headers, besides the stdafx.h file. I assume the comparative X64 stdafx.h should be pretty standard, assuming you know how to change it.

    If you look here, the code is htmlized:
    http://www2.hawaii.edu/~qzhang/FileS...her/index.html

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    stdafx.h is a project specific file, and by looking at it, I would say that it should be left as is. Unless you have a specific reason to think that is should change, that you haven't told us about. The only thing that I'd consider needing changing is that the WIN_VER && _WIN32_WINNT if you want to actually use Vista only features - but you don't need that for the existing code.

    In general, I don't see anything that would need changing to compile for 64-bit. The only worry would be if jlong is not 64-bit - then it would break the HANDLE's (since handles are pointers).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    41
    When I compile it I get this:
    fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' c:\Documents and Settings\mdg\My Documents\dev\FileSystemMonitor\Windows\Debug\File SystemWatcherNative.obj 1
    Then I have changed the target machine to: MachineX64 (/MACHINE:X64)"

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,614
    I'm guessing you need to compile on a x64 machine to make a x64 executable. That's what I'm getting from the error.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by mdoland View Post
    When I compile it I get this:
    fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' c:\Documents and Settings\mdg\My Documents\dev\FileSystemMonitor\Windows\Debug\File SystemWatcherNative.obj 1
    Then I have changed the target machine to: MachineX64 (/MACHINE:X64)"
    I think you may need to "rebuild all", perhaps [or better yet, create a different config variant, Debug64 and Release64, that are X64 variant, and keep the 32-bit variant where it is - that way you can build all 4 variants independently].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Nov 2005
    Posts
    41
    I have tried to create new platform/solution, but I can only choose between 2 existing:
    -Pocket PC 2003 (ARMV4)
    -Smartphone 2003 (ARMV4)

    If I type something new, I get an error. I have VC 2005. Maybe that is the reason?

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by mdoland View Post
    I have tried to create new platform/solution, but I can only choose between 2 existing:
    -Pocket PC 2003 (ARMV4)
    -Smartphone 2003 (ARMV4)

    If I type something new, I get an error. I have VC 2005. Maybe that is the reason?
    Not new plaform. Just a new build model - I don't know the exact term, and it's been about 4 years since I last needed to do that, compounded by not having a MS compiler environment. ARMV4 is certainly not what you want or need here.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Nov 2005
    Posts
    41
    Sorry, I realized that after I pressed send. Configuration is the name. I have created 2 new, which probably is a good start, bu I still get the same error. I saw some other thread where they did that also, but now more clues what to do.

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by mdoland View Post
    Sorry, I realized that after I pressed send. Configuration is the name. I have created 2 new, which probably is a good start, bu I still get the same error. I saw some other thread where they did that also, but now more clues what to do.
    Did you give these new configurations their own directories?

    The error you have indicates that you are trying to link a 32-bit object into a 64-bit DLL, which means that your object file needs to be rebuilt before you can link it.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #12
    Registered User
    Join Date
    Nov 2005
    Posts
    41
    There are 4 directories now. Release, Debug, X64 Release, X64 Debug
    I have cleaned and all files disappeared in the directory. They I build and get the same error again. I am trying to read some about porting to 64 bit and Vista, but no result so far. However, the stdafx.h file. Maybe some part of it gives the compiler the assumption it is in 32-bit. At least the MSDN gives me that impression.

    These variables store build and version numbers of the 32-bit Windows operating systems. These variables have been deprecated because more secure functional equivalents are available.

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by mdoland View Post
    There are 4 directories now. Release, Debug, X64 Release, X64 Debug
    I have cleaned and all files disappeared in the directory. They I build and get the same error again. I am trying to read some about porting to 64 bit and Vista, but no result so far. However, the stdafx.h file. Maybe some part of it gives the compiler the assumption it is in 32-bit. At least the MSDN gives me that impression.

    These variables store build and version numbers of the 32-bit Windows operating systems. These variables have been deprecated because more secure functional equivalents are available.
    No, the stdafx.h does not tell the compiler to make a 64- or 32-bit Object file - this is done by the compiler options in your project setting. I haven't looked at this, but perhaps you have code-generation setting as well as a linker setting for the X64?

    Also, as to the quite from MSDN, it would help a lot if you next time post a link to the original page. It doesn't matter right now, because I'm 100% sure it's not related to your problem.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #14
    Registered User
    Join Date
    Nov 2005
    Posts
    41
    Thanks for the advice about the URL references.

    I have gone through all the parameters again and still can't find anything. I found a similair issue here, though, it didn't help me.

    http://forums.msdn.microsoft.com/en-...-d1ba4a3943a7/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 12:48 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 11:38 AM
  4. If the RGB color is (64, 64, 255), change it to (64, 255, 64).
    By Grayson_Peddie in forum C# Programming
    Replies: 2
    Last Post: 06-14-2003, 04:26 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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