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

Mailing lists / fpc-pascal / 2013-09
9 messages · 3 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi All,
Could anyone explain the error in attached image?
Thanks a lot.
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
Could anyone explain the error in attached image? Thanks a lot.
http://freepascal.org/faq.var#unix-ld219
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
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<T> = 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
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
See my comment on the bug report. Additional note: The "PTree = ^TTree" in front of the…
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!
"Xiangrong Fang" wroteI 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
Additional note: The "PTree = ^TTree" in front of the "TTree" is wrong and I removed…
"Xiangrong Fang" wroteHi 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?
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<T>". 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