-
December 23rd, 2009, 07:11 AM
#1
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
-
December 23rd, 2009, 09:25 AM
#2
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__
-
December 23rd, 2009, 09:55 AM
#3
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
-
December 23rd, 2009, 12:13 PM
#4
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.
-
December 23rd, 2009, 07:58 PM
#5
Re: Platform Preprocessor Definitions
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|