Discussion:
Detect platform within DLL
(too old to reply)
Ray Mond
2009-08-18 08:39:33 UTC
Permalink
I have a DLL that's compiled to 32-bit and 64-bit platforms (x64 and
Itanium). In the 64-bit version, I would like to run some additional code.
How can I check from within the DLL if it is going to be compiled to the
64-bit version i.e.

if (platform == 64bit) // need a check here
{
some additional code...
};

Thanks in advance.


Ray Mond
Ulrich Eckhardt
2009-08-18 09:01:27 UTC
Permalink
Post by Ray Mond
I have a DLL that's compiled to 32-bit and 64-bit platforms (x64 and
Itanium). In the 64-bit version, I would like to run some additional
code. How can I check from within the DLL if it is going to be compiled to
the 64-bit version i.e.
if (platform == 64bit) // need a check here
{
some additional code...
};
You first need to decide whether you want runtime detection or compile-time
detection. Your code snippet seems to suggest the former, but you're asking
for the latter.

Anyway, I guess

#if defined(_WIN64)
...
#endif

should do the job.

Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
Ray Mond
2009-08-18 16:14:54 UTC
Permalink
Thanks, that's what I needed.


Ray Mond
Post by Ulrich Eckhardt
Post by Ray Mond
I have a DLL that's compiled to 32-bit and 64-bit platforms (x64 and
Itanium). In the 64-bit version, I would like to run some additional
code. How can I check from within the DLL if it is going to be compiled to
the 64-bit version i.e.
if (platform == 64bit) // need a check here
{
some additional code...
};
You first need to decide whether you want runtime detection or
compile-time
detection. Your code snippet seems to suggest the former, but you're asking
for the latter.
Anyway, I guess
#if defined(_WIN64)
...
#endif
should do the job.
Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
beginthreadex
2009-08-19 17:43:28 UTC
Permalink
Good solution. Perfect.

On Tue, 18 Aug 2009 11:01:27 +0200, Ulrich Eckhardt
Post by Ulrich Eckhardt
Post by Ray Mond
I have a DLL that's compiled to 32-bit and 64-bit platforms (x64 and
Itanium). In the 64-bit version, I would like to run some additional
code. How can I check from within the DLL if it is going to be compiled to
the 64-bit version i.e.
if (platform == 64bit) // need a check here
{
some additional code...
};
You first need to decide whether you want runtime detection or compile-time
detection. Your code snippet seems to suggest the former, but you're asking
for the latter.
Anyway, I guess
#if defined(_WIN64)
...
#endif
should do the job.
Uli
Continue reading on narkive:
Loading...