"Mark" <mmodrall@nospam.nospam> wrote in message
news:4DB18024-9CC0-4EB1-B66D-629692BC3018@microsoft.com...
Hi...
We're taking a pile of our old C++ and C# projects over to an x64
environment and we're running into some oddities. I've found some
article
referencing some of the pitfalls but also some things that just
aren't
lining
up.
We've added the x64 platform configuration to the solution and
that's
what
we're trying to build with.
1) our C++ projects are using pre-compiled headers, but if we build
32-bit
first then x64 we don't get a full list of compatibility problems.
Uncheck
pre-compiled headers and it explodes. Are pre-compiled headers just
not
supposed to be used for cross-platform builds?
Pre-compiled headers, like any compiler product, need to be stored in
a
separate intermediate directory for each target configuration. Just
like
dumping a mixture of debug and release object files in the same
directory
is
a recipe for disaster, so is pointing the 32-bit and 64-bit compilers
to
the
same .pch.
2) I found articles saying int and long are still 16 and 32-bits
respectively even with an x64 bit while size_t, time_t and others
supposedly
become 64-bit (major source of compiler warnings) *but*
2a) when I mouse over a size_t declaration in my code in VS, it says
"typedef unsigned int size_t;" Shouldn't that be unsigned __int64?
Of
course you can't find which include file's typedef is being used
easily.
Is
the intellisense just wrong?
int and long are 32-bits, size_t is 64-bits, and Intellisense is wrong
fairly frequently
2b) when I went searching the VC++ includes for size_t declarations
I
found
that time.h has
#if !defined (_WIN32)
#error ERROR: Only Win32 target supported
#endif
but then lower down has
#ifndef _SIZE_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 size_t;
#else
typedef _W64 unsigned int size_t;
#endif
#define _SIZE_T_DEFINED
#endif
and *still* lower down has
#ifndef _SIZE_T_DEFINED
typedef unsigned int size_t;
#define _SIZE_T_DEFINED
#endif
Especially since time.h includes crtdefs.h at the top, it doesn't
look
like
the size_t defs in time.h are active, but it does look a bit messed
up.
There are also 64-bit definitions for time_t in the file but the
stuff
at
the
top makes it look like it would blow up.
For 64-bit builds, you define both _WIN32 and _WIN64.
Any tips?
Hope this clears up the confusion.
Thanks
Mark