Re: Detecting WIN32 or .NET example in a compiler directive
- From: "Skybuck Flying" <spam@xxxxxxxxxxx>
- Date: Wed, 18 Oct 2006 22:10:58 +0200
"Rob Kennedy" <me3@xxxxxxxxxxx> wrote in message
news:4pn500Fji4kgU1@xxxxxxxxxxxxxxxxx
Skybuck Flying wrote:
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 ;))
Indeed. There's no reason to have two.
In your particular example, there's no reason for the compiler directives
at all. Writeln and Readln work fine in .Net. They're defined as part of
the Delphi language.
Yeah, I realised this after I made the examples. I wanted to use a typical
..net object. I ended up using
Console.WriteLn to proof that it's really a .net program.
However it seems it is necessary to create two different projects, one
for win32 and one for .net.
Yeah. So?
If you want to switch, close the project and re-open the DPR file. The IDE
will ask which environment you want to use.
There are three IDE's it seems (not mentioning the C things):
Borland Developer Studio
Delphi for Win32
Delphi for .NET
Switching between Win32 and .Net projects is only possible when Studio was
started.
The other two IDE's do not allow it.
I can't even open a Win32 VCL Form in Delphi for .NET, I have to use the
Studio to be able to do that ?!
Maybe it's possible to create one project and simply use a compiler
directive to switch between compile environments ???
The problem is that it's really two different compilers. Compiler
directives are processed by the compiler, obviously, but once you've
invoked a compiler, it's too late to choose which one you want in a
compiler directive.
Well it shouldn't be to hard to create a super compiler or intermediate
compiler or a proxy or something =D
Win32 and .NET settings might as well be integrated into one project file.
More like Visual Studio of Microsoft where all kinds of compiler settings
and output can be specified.
Also the help file of Delphi could be improved so that I can use the wheel
mouse to easily scroll the index, now I have to first click the index tab at
the bottom before I can use the wheel mouse.
Another little improvement ;) However that might have to be done by
microsoft.... since it might be there help application.
Bye,
Skybuck.
.
- Follow-Ups:
- Re: Detecting WIN32 or .NET example in a compiler directive
- From: Rob Kennedy
- Re: Detecting WIN32 or .NET example in a compiler directive
- References:
- Detecting WIN32 or .NET example in a compiler directive
- From: Skybuck Flying
- Re: Detecting WIN32 or .NET example in a compiler directive
- From: Rob Kennedy
- Detecting WIN32 or .NET example in a compiler directive
- Prev by Date: Re: NT Service and Sockets
- Next by Date: Re: {$ELSEIF} not working in Delphi 2006 ?
- Previous by thread: Re: Detecting WIN32 or .NET example in a compiler directive
- Next by thread: Re: Detecting WIN32 or .NET example in a compiler directive
- Index(es):
Relevant Pages
|