CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Compiling on an x86 CPU

    I'm compiling some open source code (originally written for Linux / gcc) which uses the following line to determine if a particular section is being compiled for an x86 processor:-

    Code:
    #if ( defined(__x86_64__) || defined(__i386__) )
    Sadly, neither of those seems to be defined by my ageing compiler (VC++ 8.0). What would be the equivalent for building with VC8 ?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Compiling on an x86 CPU

    not that used to defines on gcc.

    but I would guess....
    for __x86_64__
    -> _WIN64

    the second not entirely sure, depends on meaning if it specifies the target (which it propbably does) machine
    then
    _M_IX86 >= 300
    which will always be the case for VS (if it's not _WIN64) since it can't target anything less than a 386.

  3. #3
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Compiling on an x86 CPU

    Thanks OReubens. Something occurred to me just after I posted - am I right in thinking that MSVC can only target the x86 architecture? If so, I guess I could just test for _MSC_VER

    [Edit...] No, I think I'm wrong about that. It seems like ARM processors are also supported (and possibly others).

    However, I discovered one called _M_X64. So perhaps a combination of _M_X64 and _M_IX86 might do the trick ?
    Last edited by John E; April 30th, 2015 at 09:20 AM.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  4. #4
    Join Date
    Nov 2003
    Posts
    1,902

  5. #5
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Compiling on an x86 CPU

    That's a really interesting list. Thanks for finding it.!

    What's Itanium BTW?? I only ever hear it mentioned in relation to servers so I've never been 100% certain. Is it related to x86 or something entirely different? For example, my PC uses an Intel Core 2 Duo (which I regard as part of the x86 family). But I'm pretty sure it would run a 64-bit OS. So does that make it an Itanium chip - or is Itanium totally different?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  6. #6
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Compiling on an x86 CPU

    Totally different. Normal 64bit is what that site calls "AMD64".

    https://en.wikipedia.org/wiki/Itanium

    gg

  7. #7
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Compiling on an x86 CPU

    The itanium is a RISC based 64-bit processor jointly developed by then DEC (now HP) and Intel.
    It is NOT x86, though it did have a means to efficiently run x86 code in a VM hosted in the OS.

    Microsoft recently announced it would no longer support the itanium in upcoming versions of Windows.
    Which pretty much means an end of the line for the itanium as a whole.

    THe itanium never was a good seller and all companies involved essentially pumped lots of money into the project. But other technologies caught up with the hole the itanium was intended to plug, such as x64, multi cores , hyperthreading, increasing speeds, internal pipelining etc etc etc. So while a lot of promise on paper, the itanium was Always sort of limping behind the more consumer oriented CPU's that got more attention and optimisations due to being moneymakers whereas the itanium never was.

    It looks as though MS is finding more solace in supporting the ARM, which is/was already popular in units sold (pretty much every mobile device, as well as a lot of applicances like TV's, Dvd's, dishwashers... use arm's), but is now rapidly moving ahead in supported CPU clockspeeds, and the latest version of the ARM instruction set is getting instructions to (better) support more complex OSes like WIndows and Unix.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured