lul.pas does not compile with fpc 2.2.0

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

lul.pas does not compile with fpc 2.2.0

Skybuck Flying
Hi,

The following simple and valid Delphi code does not compile with command:

fpc lul.pas

// *** Begin of Code ***

unit lul;

interface

type
 Tpenis = class
 private

 public

 end;

implementation


end.

// *** End of Code ***

// *** Begin of Output ***

<snip>fpc lul.pas
Free Pascal Compiler version 2.2.0 [2007/09/09] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Win32 for i386
Compiling lul.pas
lul.pas(10,2) Error: Identifier not found "class"
lul.pas(10,2) Error: Error in type definition
lul.pas(10,2) Fatal: Syntax error, ";" expected but "identifier PRIVATE"
found
Fatal: Compilation aborted
Error: C:\Tools\Compilers\Free Pascal\2.2.0 Stable for
Win32\bin\i386-Win32\ppc3
86.exe returned an error exitcode (normal if you did not specify a source
file t
o be compiled)

// *** End of Output ***

What's the problem ?

Bye,
  Skybuck.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

ik-6
It's simple, you declared a prototype of a class, so you do not need
to declare the entire structure of the class.

type
  Tpenis = class;

and that's it

Ido

On Feb 9, 2008 10:04 PM, Skybuck Flying <[hidden email]> wrote:

> Hi,
>
> The following simple and valid Delphi code does not compile with command:
>
> fpc lul.pas
>
> // *** Begin of Code ***
>
> unit lul;
>
> interface
>
> type
>  Tpenis = class
>  private
>
>  public
>
>  end;
>
> implementation
>
>
> end.
>
> // *** End of Code ***
>
> // *** Begin of Output ***
>
> <snip>fpc lul.pas
> Free Pascal Compiler version 2.2.0 [2007/09/09] for i386
> Copyright (c) 1993-2007 by Florian Klaempfl
> Target OS: Win32 for i386
> Compiling lul.pas
> lul.pas(10,2) Error: Identifier not found "class"
> lul.pas(10,2) Error: Error in type definition
> lul.pas(10,2) Fatal: Syntax error, ";" expected but "identifier PRIVATE"
> found
> Fatal: Compilation aborted
> Error: C:\Tools\Compilers\Free Pascal\2.2.0 Stable for
> Win32\bin\i386-Win32\ppc3
> 86.exe returned an error exitcode (normal if you did not specify a source
> file t
> o be compiled)
>
> // *** End of Output ***
>
> What's the problem ?
>
> Bye,
>   Skybuck.
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



--
http://ik.homelinux.org/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Mattias Gaertner
On Sat, 9 Feb 2008 22:04:33 +0200
ik <[hidden email]> wrote:

> It's simple, you declared a prototype of a class, so you do not need
> to declare the entire structure of the class.
>
> type
>   Tpenis = class;
>
> and that's it

No.
He probably forgot to enable Delphi mode.
See here
http://wiki.lazarus.freepascal.org/Code_Conversion_Guide
and especially here:
http://wiki.lazarus.freepascal.org/Code_Conversion_Guide#Selecting_the_right_compiler_mode


Mattias


>
> Ido
>
> On Feb 9, 2008 10:04 PM, Skybuck Flying <[hidden email]>
> wrote:
> > Hi,
> >
> > The following simple and valid Delphi code does not compile with
> > command:
> >
> > fpc lul.pas
> >
> > // *** Begin of Code ***
> >
> > unit lul;
> >
> > interface
> >
> > type
> >  Tpenis = class
> >  private
> >
> >  public
> >
> >  end;
> >
> > implementation
> >
> >
> > end.
> >
> > // *** End of Code ***
> >
> > // *** Begin of Output ***
> >
> > <snip>fpc lul.pas
> > Free Pascal Compiler version 2.2.0 [2007/09/09] for i386
> > Copyright (c) 1993-2007 by Florian Klaempfl
> > Target OS: Win32 for i386
> > Compiling lul.pas
> > lul.pas(10,2) Error: Identifier not found "class"
> > lul.pas(10,2) Error: Error in type definition
> > lul.pas(10,2) Fatal: Syntax error, ";" expected but "identifier
> > PRIVATE" found
> > Fatal: Compilation aborted
> > Error: C:\Tools\Compilers\Free Pascal\2.2.0 Stable for
> > Win32\bin\i386-Win32\ppc3
> > 86.exe returned an error exitcode (normal if you did not specify a
> > source file t
> > o be compiled)
> >
> > // *** End of Output ***
> >
> > What's the problem ?
> >
> > Bye,
> >   Skybuck.
> >
> > _______________________________________________
> > fpc-pascal maillist  -  [hidden email]
> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> >
>
>
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Skybuck Flying
In reply to this post by ik-6
Nope.

More complex units did not compile as well.

Example of slightly more complex unit:

// *** begin of code ***
unit lul;

interface

type
 Tpenis = class
 private
  a : integer;
 public

 end;

implementation


end.

// *** end of code ***

Your reasoning doesn't make any sense anyway.

It's perfectly fine to declare a empty class like in my example.

Bye,
  Skybuck.

----- Original Message -----
From: "ik" <[hidden email]>
To: "FPC-Pascal users discussions" <[hidden email]>
Sent: Saturday, February 09, 2008 9:04 PM
Subject: Re: [fpc-pascal] lul.pas does not compile with fpc 2.2.0


> It's simple, you declared a prototype of a class, so you do not need
> to declare the entire structure of the class.
>
> type
>  Tpenis = class;
>
> and that's it
>
> Ido
>
> On Feb 9, 2008 10:04 PM, Skybuck Flying <[hidden email]> wrote:
>> Hi,
>>
>> The following simple and valid Delphi code does not compile with command:
>>
>> fpc lul.pas
>>
>> // *** Begin of Code ***
>>
>> unit lul;
>>
>> interface
>>
>> type
>>  Tpenis = class
>>  private
>>
>>  public
>>
>>  end;
>>
>> implementation
>>
>>
>> end.
>>
>> // *** End of Code ***
>>
>> // *** Begin of Output ***
>>
>> <snip>fpc lul.pas
>> Free Pascal Compiler version 2.2.0 [2007/09/09] for i386
>> Copyright (c) 1993-2007 by Florian Klaempfl
>> Target OS: Win32 for i386
>> Compiling lul.pas
>> lul.pas(10,2) Error: Identifier not found "class"
>> lul.pas(10,2) Error: Error in type definition
>> lul.pas(10,2) Fatal: Syntax error, ";" expected but "identifier PRIVATE"
>> found
>> Fatal: Compilation aborted
>> Error: C:\Tools\Compilers\Free Pascal\2.2.0 Stable for
>> Win32\bin\i386-Win32\ppc3
>> 86.exe returned an error exitcode (normal if you did not specify a source
>> file t
>> o be compiled)
>>
>> // *** End of Output ***
>>
>> What's the problem ?
>>
>> Bye,
>>   Skybuck.
>>
>> _______________________________________________
>> fpc-pascal maillist  -  [hidden email]
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
>
> --
> http://ik.homelinux.org/
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Skybuck Flying
In reply to this post by Mattias Gaertner
Yeah, well, what exactly is the difference ?

The guide doesn't explain.

I assume free pascal does support the "class" keyword ?

Bye,
  Skybuck.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Vincent Snijders
Skybuck Flying schreef:
> Yeah, well, what exactly is the difference ?
>
> The guide doesn't explain.
>
> I assume free pascal does support the "class" keyword ?
>

The default compiler mode is {$mode fpc} which is more TP compatible.
Turbo Pascal did not support the class keyword either.

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Skybuck Flying
Doesn't make much sense to me at least.

Who still codes in 16 bit or turbo pascal ?

64 KB programs ?

Terrible limitations.

I am glad those days are dead/gone/over.

Bye,
  Skybuck.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Giuliano Colla
Skybuck Flying ha scritto:

> Doesn't make much sense to me at least.
>
> Who still codes in 16 bit or turbo pascal ?
>
> 64 KB programs ?
>
> Terrible limitations.
>
> I am glad those days are dead/gone/over.
>
If you want Delphi mode, you just put
{$Mode Delphi}
at the beginning of your unit, among the other compiler switches (if any).
If you don't, you get the default fpc mode, which requires a stricter
syntax.

type TPenis = class // accepted in Delphi mode
is a shortcut for
type TPenis = class(TObject) // required in fpc mode
In both cases TPenis is a descendant of TObject, but in Delphi mode case
you don't see it.

 From Delphi manual page:
<begin quote>
If the declaration of a class type doesn't specify an ancestor, the
class inherits directly from TObject. Thus
type TMyClass = class
...
end;
is equivalent to
type TMyClass = class(TObject)
...
end;

The latter form is recommended for readability.
<end quote>

So if you follow Delphi manuals recommendation, you don't see the
difference, from 16 bits TP to 64 bit  fpc. If you choose not to follow
them, then you must specify that you want Delphi mode.

Another difference you'll find from fpc mode to Delphi mode is the
implicit pointer accepted for constructs such as:
MyObjectOnClick := Button1Click; // accepted in Delphi mode
as opposed to:
MyObjectOnClick := @Button1Click; // required in fpc mode

I'd suggest you to read the wiki pages from Mattias reply.

Giuliano

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Peter Vreman
In reply to this post by Skybuck Flying
Skybuck Flying wrote:
> Doesn't make much sense to me at least.
>
> Who still codes in 16 bit or turbo pascal ?
>
> 64 KB programs ?
>
> Terrible limitations.
>
> I am glad those days are dead/gone/over.

It was discussed already a couple of years ago to make objfpc the
default compile mode. But it breaks too much existing code. We have to
think about backwards compatibility.

Peter
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Marco van de Voort
In reply to this post by Skybuck Flying
> Doesn't make much sense to me at least.
>
> Who still codes in 16 bit or turbo pascal ?

A few.
 
> 64 KB programs ?

> Terrible limitations.

Agreed, but the FPC mode doesn't have these limitations. It is a TP dialect
compability, but otherwise a full 32/64 bit mode. The compiler itself is
written in it for a large part.

IOW one can probably perfectly write 64-bit compatible TP code and use a few tens of
GBs of memory.
 
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: lul.pas does not compile with fpc 2.2.0

Joao Morais
In reply to this post by Peter Vreman
Peter Vreman wrote:

> Skybuck Flying wrote:
>> Doesn't make much sense to me at least.
>>
>> Who still codes in 16 bit or turbo pascal ?
>>
>> 64 KB programs ?
>>
>> Terrible limitations.
>>
>> I am glad those days are dead/gone/over.
>
> It was discussed already a couple of years ago to make objfpc the
> default compile mode. But it breaks too much existing code. We have to
> think about backwards compatibility.

Not a problem IMHO, since one can include objfpc mode within fpc.cfg file.

--
Joao Morais
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal