Conditional compilation issue.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Conditional compilation issue.

  1. #1
    Join Date
    Jan 2007
    Posts
    142

    Thumbs up Conditional compilation issue.

    Hi,
    I want to do conditional compilation based on whether it is windows 7 or windows 8. Here is the code below.

    #if (_WIN32_WINNT >= 0x0602) //Condition to check whether it windows 7 or 8 .Based on this we can load msxml 3 or 6.
    #import <msxml6.dll>
    #else
    #import <msxml3.dll>
    #endif

    Im building the above code in windows 8 machine.

    Issue here is _WIN32_WINNT should have a value 0x0602, it means it is running in windows 8 machine.Instead it has a value 0x0601 (Means it is taking windows version as windows 7 defined in sdkddkver.h).Im not sure after installing windows 8 sdk im not able to see any include or lib files in the path below C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A . but i can see all include and lib files of sdk version v7.0A available although i did not installed it.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,288

    Re: Conditional compilation issue.

    Did you try to add
    Code:
    #define _WIN32_WINNT 0x0602
    into atdafx.h (before all the #includes?)
    Victor Nijegorodov

  3. #3
    Join Date
    Jan 2007
    Posts
    142

    Re: Conditional compilation issue.

    thanks, this link http://blogs.msdn.com/b/vcblog/archi.../10287354.aspx helped me to resolve the issue ..

    procedure followed to resolve the issue.
    1)install windows 8 sdk.
    2)set the path of windows 8 sdk.

    But facing new issue. when i try to import msxml3.dll it is not generating .tlh and .tlb file in outpt directory

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,927

    Re: Conditional compilation issue.

    Well, importing this or that COM type library, which is what importing dll is really about, has nothing to do with Windows version the compilation occurs in, as well as Platform SDK version.

    These are interfaces that msxml3.dll has impelented compared to msxml6.dll:
    Code:
    struct __declspec(uuid("65725580-9b5d-11d0-9bfe-00c04fc99c8e"))
    /* dual interface */ IXMLElementCollection;
    struct __declspec(uuid("f52e2b61-18a1-11d1-b105-00805f49916b"))
    /* dual interface */ IXMLDocument;
    struct __declspec(uuid("3f7f31ac-e15f-11d0-9c25-00c04fc99c8e"))
    /* dual interface */ IXMLElement;
    struct __declspec(uuid("2b8de2fe-8d2d-11d1-b2fc-00c04fd915a9"))
    /* interface */ IXMLDocument2;
    struct __declspec(uuid("2b8de2ff-8d2d-11d1-b2fc-00c04fd915a9"))
    /* dual interface */ IXMLElement2;
    struct __declspec(uuid("d4d4a0fc-3b73-11d1-b2b4-00c04fb92596"))
    /* dual interface */ IXMLAttribute;
    struct __declspec(uuid("948c5ad3-c58d-11d0-9c0b-00c04fc99c8e"))
    /* interface */ IXMLError;
    struct _xml_error;
    enum tagXMLEMEM_TYPE;
    In case your code does mot make any use of these, it must be indifferent to what exact dll you import on compilation phase.
    Best regards,
    Igor

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,927

    Re: Conditional compilation issue.

    As a final resort you may extract type library from any of the dlls and import the one, directly and explicitly, on any platform where you compile.
    Best regards,
    Igor

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,765

    Re: Conditional compilation issue.

    you don't need to do this.
    you can use msxml3 on windows 8

    note that what you are doing here is create an exe that is conditional on the _WIN32_WINNT define.
    This does not in any way or form make an exe that will run differently depending on what OS the exe is running on.

    With 2 separate compiles and 2 separate exe's, you can make an exe that is "meant for win7" and another that is "meant for Win8" but unless you have actual provisions for it, either exe will run on either OS, in so far as the used dll's and imported functions are present. If they aren't you will get a rather cryptic message stating that a certain function from a certain (system) dll cannot be found.

    There is also no relation to the build machine. you can build windows 8 binaries on an older windows machine and vice verse in so far as you have installed the platform SDK's, running/debugging the exe is another matter of course.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center