Platform Preprocessor Definitions
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Platform Preprocessor Definitions

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

    Platform Preprocessor Definitions

    Using VS2005 I'm building a source library that was originally written to be compiled using gcc. A couple of modules have code that looks like this:-

    Code:
    #if defined(__i386__) || defined(__x86_64__)
        // Do something
    #elif defined(__powerpc__)
        // Do something else
    #elif defined(__alpha__)
        // Do something else
    #elif defined(__mips__)
        // etc, etc
    #endif
    For most of the above I wouldn't expect them to be recognised by VC++ because it can't cross-compile for powerpc, mips alpha or whatever. However, VC++ doesn't even recognise __i386__ or __x86_64__

    Are there any equivalent identifiers that VC++ will recognise?
    "A problem well stated is a problem half solved. - Charles F. Kettering

  2. #2
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Platform Preprocessor Definitions

    GCC doesn't have built in macros for those either, you have to define them in the project file. Certain IDEs will automatically define those for you when it creates the project. I'm pretty sure XCode does, which is what I assume you were using by the __powerpc__ macro. I think the Visual C++ argument is the same as GCC -D __x86_64__

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

    Re: Platform Preprocessor Definitions

    Are you sure about that? I always thought that definitions beginning with a double underscore (__mips__ / __alpha__ / __powerpc__ etc) were somehow predetermined by the compiler. In fact I'm pretty sure they are, although I don't know how.
    "A problem well stated is a problem half solved. - Charles F. Kettering

  4. #4
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Platform Preprocessor Definitions

    Huh, I guess I was wrong, it is predetermined by the compiler. But it's not standard, it's predetermined by the GCC compiler. GCC does this, MinGW doesn't (I just tested it), so I would assume VC++ doesn't either. It shouldn't be hard to define though in your project. I'm not sure where you define the global definitions, but I know there is a way to do it.

  5. #5
    Join Date
    Nov 2003
    Posts
    1,793

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