Detecting WIN32 or .NET example in a compiler directive
- From: "Skybuck Flying" <spam@xxxxxxxxxxx>
- Date: Wed, 18 Oct 2006 12:37:33 +0200
Hello,
I post this example because it might become handy in the future:
The question was how to detect WIN32 or .NET in a compiler directive.
***********************
* WIN32 example: *
***********************
*** Begin of Code ***:
program ProjectDetectWin32;
{$APPTYPE CONSOLE}
uses
SysUtils;
begin
{$IF DEFINED(WIN32)}
WriteLn('Welcome to the WIN32 world !');
Readln;
{$ELSEIF DEFINED(CLR)}
Console.WriteLine('Welcome to the .NET world !');
Console.ReadLine;
{$ELSE}
*** unknown world ;) ***
{$IFEND}
end.
*** End of Code ***
*********************
* .NET example: *
*********************
*** Begin of Code ***:
program ProjectDetectDotNet;
{$APPTYPE CONSOLE}
uses
SysUtils;
begin
{$IF DEFINED(WIN32)}
WriteLn('Welcome to the WIN32 world !');
Readln;
{$ELSEIF DEFINED(CLR)}
Console.WriteLine('Welcome to the .NET world !');
Console.ReadLine;
{$ELSE}
*** unknown world ;) ***
{$IFEND}
end.
*** End of Code ***
As you can see the code is exactly the same (except for the program
directive which does nothing ;))
However it seems it is necessary to create two different projects, one for
win32 and one for .net.
Maybe it's possible to create one project and simply use a compiler
directive to switch between compile environments ???
Bye,
Skybuck.
.
- Follow-Ups:
- Re: Detecting WIN32 or .NET example in a compiler directive
- From: Marc Rohloff
- Re: Detecting WIN32 or .NET example in a compiler directive
- From: Rob Kennedy
- Re: Detecting WIN32 or .NET example in a compiler directive
- Prev by Date: Re: {$ELSEIF} not working in Delphi 2006 ?
- Next by Date: NT Service and Sockets
- Previous by thread: {$ELSEIF} not working in Delphi 2006 ?
- Next by thread: Re: Detecting WIN32 or .NET example in a compiler directive
- Index(es):
Relevant Pages
|