Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-02

lul.pas does not compile with fpc 2.2.0

11 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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.

Reply by email

ik
to Skybuck Flying

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

Skybuck Flying wrote 56 lines
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 - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Mattias Gaertner
to ik
Show quoted text 7 lines
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

Show quoted text 65 lines
Ido On Feb 9, 2008 10:04 PM, Skybuck Flying 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 - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Reply by email

Skybuck Flying
to ik: It's simple, you declared a prototype of a class, so you do not need to declare the…

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.

Earlier message 83 lines
----- Original Message ----- From: "ik" To: "FPC-Pascal users discussions" 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 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 - >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal >> > > > > -- > http://ik.homelinux.org/ > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Reply by email

Vincent Snijders
to Skybuck Flying
Skybuck Flying wrote 6 lines
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

Reply by email

Giuliano Colla
to Skybuck Flying

Skybuck Flying ha scritto:

Show quoted text 10 lines
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

Reply by email

Peter Vreman
to Skybuck Flying: Doesn't make much sense to still codes in 16 bit or turbo pascal ? 64 KB programs ?…
Skybuck Flying wrote 9 lines
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

Reply by email

Marco van de Voort
to Skybuck Flying: Doesn't make much sense to still codes in 16 bit or turbo pascal ? 64 KB programs ?…
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.

Reply by email

Joao Morais
to Peter Vreman: It was discussed already a couple of years ago to make objfpc the default compile mode.…
Peter Vreman wrote 14 lines
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

Reply by email