Sign in Join

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

Mailing lists / fpc-devel / 2009-09

PDF on C/C++ code in Free Pascal

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Gilles MARCOU

Hello,

I am sorry to bother all of you about this small problem. In 2006, I have written a small text about binding C/C++ code into Free Pascal projects. I have written an updated version of this text and I'd like to replace the current version on the Free Pascal server (ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf). I have contacted some persons of the Free Pascal community to ask for the update. But since then I have recieved no answer. How should I require an update of this file?

By the way, I am open to all suggestions to improve this text.

Thanks,
Gilles Marcou

Reply by email

Jonas Maebe
to Gilles MARCOU
Gilles MARCOU wrote 9 lines
I am sorry to bother all of you about this small problem. In 2006, I have written a small text about binding C/C++ code into Free Pascal projects. I have written an updated version of this text and I'd like to replace the current version on the Free Pascal server (ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf). I have contacted some persons of the Free Pascal community to ask for the update. But since then I have recieved no answer. How should I require an update of this file?

The best way is to file a bug report at http://bugs.freepascal.org and attach the new file. Then anyone who can replace files on ftp.freepascal.org (which includes quite a few people) can perform the replacement.

Thanks,

Jonas

Reply by email

Sven Barth

(I hope this gets attached to the right thread, cause I just registered to fpc-devel)

Hi!

Gilles MARCOU wrote
By the way, I am open to all suggestions to improve this text.

What about documenting the 'cppclass' feature of Free Pascal? I found this a few weeks ago and digged in the compilers code. From what I saw it should still work with gcc 3.x/4.x compiled cpp code. But I didn't test how. The only documentation is that you can't mix normal class hierarchy with a cppclass one...

Regards,
Sven

Reply by email

Jonas Maebe
to Sven Barth
Sven Barth wrote 5 lines
What about documenting the 'cppclass' feature of Free Pascal? I found this a few weeks ago and digged in the compilers code. From what I saw it should still work with gcc 3.x/4.x compiled cpp code. But I didn't test how. The only documentation is that you can't mix normal class hierarchy with a cppclass one...

As far as I know, there is not a single test for this functionality, so I'm not sure that it actually works.

Jonas

Reply by email

Sven Barth
to Jonas Maebe
As far as I know, there is not a single test for this functionality, so I'm not sure that it actually works.

Well... then I think it's time to change this.

I'll try to test this functionality (and to fix it, if it fails), but you (or another core developer) should at least tell me how that feature is supposed to work and (equally important) be used.

I'd love to see Free Pascal as a compiler that supports linking to C++ libraries (even if they are only GCC ones).

Regards,
Sven

Reply by email

Jonas Maebe
to Sven Barth
Sven Barth wrote 7 lines
Jonas Maebe schrieb: > As far as I know, there is not a single test for this > functionality, so I'm not sure that it actually works. Well... then I think it's time to change this. I'll try to test this functionality (and to fix it, if it fails),

Thanks!

but you (or another core developer) should at least tell me how that feature is supposed to work and (equally important) be used.

Frankly, I don't really know. I only discovered this by chance while working on the Objective-C support. As far as I could tell, you simply have to use "cppclass" rather than "class", and that's it (the cppdecl name mangling style is automatically applied to all methods afterwards, if I remember correctly). I don't think that field accesses can work at all though, nor calling virtual methods (let alone defining multiple inheritance hierarchies). The only thing that really seemed to be implemented was C++ name mangling.

Jonas

Reply by email

Florian Klaempfl
to Jonas Maebe
Show quoted text 24 lines
On 16 Sep 2009, at 20:09, Sven Barth wrote: > Jonas Maebe schrieb: >> As far as I know, there is not a single test for this functionality, >> so I'm not sure that it actually works. > > Well... then I think it's time to change this. > > I'll try to test this functionality (and to fix it, if it fails), Thanks! > but you (or another core developer) should at least tell me how that > feature is supposed to work and (equally important) be used. Frankly, I don't really know. I only discovered this by chance while working on the Objective-C support. As far as I could tell, you simply have to use "cppclass" rather than "class", and that's it (the cppdecl name mangling style is automatically applied to all methods afterwards, if I remember correctly). I don't think that field accesses can work at all though, nor calling virtual methods (let alone defining multiple inheritance hierarchies). The only thing that really seemed to be implemented was C++ name mangling.

The code is already very old. It worked for very simply classes and gcc 2.95 iirc. But nobody continued so far to improve it.

Reply by email

Sven Barth
to Jonas Maebe: Thanks! Frankly, I don't really know. I only discovered this by chance while working on…
Show quoted text 12 lines
On 16 Sep 2009, at 20:09, Sven Barth wrote: > Jonas Maebe schrieb: >> As far as I know, there is not a single test for this functionality, >> so I'm not sure that it actually works. > > Well... then I think it's time to change this. > > I'll try to test this functionality (and to fix it, if it fails), Thanks!

But I can't say when I'll have the time for it. Some weeks/months more won't matter with this old feature ^^

Show quoted text 10 lines
Frankly, I don't really know. I only discovered this by chance while working on the Objective-C support. As far as I could tell, you simply have to use "cppclass" rather than "class", and that's it (the cppdecl name mangling style is automatically applied to all methods afterwards, if I remember correctly). I don't think that field accesses can work at all though, nor calling virtual methods (let alone defining multiple inheritance hierarchies). The only thing that really seemed to be implemented was C++ name mangling.

Virtual methods would have been cool... So we would be able to import e. g. the Irrlicht library in a very easy way ^^

(although I think this message will be posted between Jonas' and Florian's, I will quote Florian here, cause I'm using digest mode and don't know how to answer him more directly (in the list))

The code is already very old. It worked for very simply classes and gcc 2.95 iirc. But nobody continued so far to improve it.

The little searching that I did in the compiler's source tells me that it already supports gcc 3.x (and with this 4.x) name mangling. So it *should* work with gcc 3+. But whether it works is indeed another story ^^

If someone would be willing to extend this feature (virtual methods, perhaps multiple inheritance) would this be welcomed? I don't know if I'll find the time to do that, but I think it would certainly increase my knowledge about the compiler ^^ (but first I'll steer the Native NT port into a save harbour :) )

Regards,
Sven

Reply by email