Re: [fpc-pascal] Re: weird compile error message

2013-09-11 Thread Sven Barth
Am 12.09.2013 03:14 schrieb "Xiangrong Fang" :
>
> Hi Sven,
>
>> Additional note: The "PTree = ^TTree" in front of the "TTree" is wrong
and only supported by pre-2.7.1 FPC by accident. The correct code would be:
>
>
> I removed PTree yesterday and this problem is gone.  I now understand
that it is not necessary to define PTree as TTree is a pointer anyway.
However, I don't understand why it is WRONG.  I mean, is the problem I
reported caused by this definition? If so, why it disappeared while the
debug-info-generation option is turned off?
>
> Say, the following is normal in pascal:
>
> type
>   PMyRecord = ^TMyRecord;
>   TMyRecord = record
>   ... ...
>   end;
>
> Why it is wrong to define PTree = ^TTree?   Is it because that this kind
of pointer definition is:
> only valid for record, but not class?
> only valid for record and NON-generic class?

It is wrong, because the type "TTree" does jot exist. Only "TTree". But
you can not use that before the generic is declared, because the "T" would
be unknown then and also when specializing the compiler would not be able
to know that it would need to somehow specialize "PTree" as well as it does
not know (from the perspective of "TTree") that something is pointing at
"TTree". That's why you need to declare "PTree" inside the generic (this
was one of the reasons why nested types were added).

And this reason combined with a bug in the compiler resulted in your error
message. The 2.7.1 compiler will present you the error that the usage of
generics without specialization is not allowed.

Otherwise pointers to classes are principally allowed, but I don't see a
use in them, because classes are already pointers.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: weird compile error message

2013-09-11 Thread Sven Barth
Am 12.09.2013 03:46 schrieb "Xiangrong Fang" :
> I have downloaded fpcbuild.zip and did 'NOGDB=1 make build', as it tell
me cannot find libgdb.a...

Just ignore the libgdb stuff. It's only needed for the textmode IDE.

> Now my question is how can I install the binaries so that it does NOT
interfere with my current 2.6.2 build?

Use the following in the source directory of a FPC 2.7.1 to install to a
directory of your choice:

make clean all install INSTALL_PREFIX=/wherever/you/want

Then copy your ~/.fpc.cfg or /etc/fpc.cfg to e.g. ~/.fpc.2.7.1.cfg and
adjust all paths in there.

To compile programs you now need the following:
- add /wherever/you/want/bin and /wherever/you/want/lib/fpc/2.7.1 to your
$PATH (maybe only temporary for your current console session)
- call fpc with the following arguments (in addition to other options you
might need): fpc -n @~/.fpc.2.7.1.cfg [other options]

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: weird compile error message

2013-09-11 Thread Xiangrong Fang
Hi Sven,

I have downloaded fpcbuild.zip and did 'NOGDB=1 make build', as it tell me
cannot find libgdb.a...

Now my question is how can I install the binaries so that it does NOT
interfere with my current 2.6.2 build?

Thanks!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: weird compile error message

2013-09-11 Thread Xiangrong Fang
Hi Sven,

Additional note: The "PTree = ^TTree" in front of the "TTree" is wrong and
> only supported by pre-2.7.1 FPC by accident. The correct code would be:
>

I removed PTree yesterday and this problem is gone.  I now understand that
it is not necessary to define PTree as TTree is a pointer anyway.  However,
I don't understand why it is WRONG.  I mean, is the problem I reported
caused by this definition? If so, why it disappeared while the
debug-info-generation option is turned off?

Say, the following is normal in pascal:

type
  PMyRecord = ^TMyRecord;
  TMyRecord = record
  ... ...
  end;

Why it is wrong to define PTree = ^TTree?   Is it because that this kind of
pointer definition is:

   1. only valid for record, but not class?
   2. only valid for record and NON-generic class?


Xiangrong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: weird compile error message

2013-09-11 Thread Sven Barth

On 11.09.2013 17:01, Xiangrong Fang wrote:

Hi,

"Missing -T" is not the problem, the problem is "undefined reference",
which caused fatal error.

I filed a bug report: http://bugs.freepascal.org/view.php?id=25001

I am pretty sure this is a bug, becuase while I continue to add code to
my TTree class, this problem is gone!  In another word, it seems only
occur in the code I attached in that bug report.

Maybe someone in charge of the compiler can analyze the problem ?


See my comment on the bug report.

Additional note: The "PTree = ^TTree" in front of the "TTree" is wrong 
and only supported by pre-2.7.1 FPC by accident. The correct code would be:


=== code begin ===

type
  generic TTree = class
  public type
PTree = ^TTree;
  private
...
  end;

=== code end ===

Though this type and the "FParent: PTree" part wouldn't be needed 
anyway. "FParent: TTree" is sufficient and the property can be declared 
as "property Parent: TTree read FParent".


I suggest you to test generic related code with 2.7.1 as well to check 
whether code is a) still supported (and then ask here whether it's 
intended that something is not supported any longer) or b) already fixed 
if it's something that does not work in 2.6.x


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: weird compile error message

2013-09-11 Thread Xiangrong Fang
Hi,

"Missing -T" is not the problem, the problem is "undefined reference",
which caused fatal error.

I filed a bug report: http://bugs.freepascal.org/view.php?id=25001

I am pretty sure this is a bug, becuase while I continue to add code to my
TTree class, this problem is gone!  In another word, it seems only occur in
the code I attached in that bug report.

Maybe someone in charge of the compiler can analyze the problem ?

Thanks!



2013/9/11 leledumbo 

> http://freepascal.org/faq.var#unix-ld219
>
>
>
> --
> View this message in context:
> http://free-pascal-general.1045716.n5.nabble.com/weird-compile-error-message-tp5716396p5716421.html
> Sent from the Free Pascal - General mailing list archive at Nabble.com.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Re: weird compile error message

2013-09-11 Thread leledumbo
http://freepascal.org/faq.var#unix-ld219



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/weird-compile-error-message-tp5716396p5716421.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: weird compile error message

2013-09-11 Thread Xiangrong Fang
Hi,

I found the problem, but don't know the cause or how to fix it.

First of all, my main code (project1.lpr) has just added the tree unit into
"uses", but not actually use any of it.

The problem occurs if I compile it using the Lazarus settings:

fpc -MObjFPC -Scghi -O1 -g -gl -vewnhi -Filib/x86_64-linux -Fu.
-FUlib/x86_64-linux/ -l project1.lpr

However if I remove these -F, it is OK:

fpc -MObjFPC -Scghi -O1 -g -gl -vewnhi -l project1.lpr

Is this a bug in the compiler?  I attached the complete source (3 files) so
that you can test it.

Thanks a lot!



2013/9/11 Xiangrong Fang 

> Hi All,
>
> Could anyone explain the error in attached image?
>
> Thanks a lot.
>
>


tree.tar.bz2
Description: BZip2 compressed data
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal