PDA

View Full Version : C++ also available in Delphi?



masonwheeler
10-10-2007, 08:46 PM
I read somewhere that Borland C++ Builder comes with the Delphi compiler included, allowing developers to use Object Pascal code in their C++ Builder projects. Does it work the other way too? If there's a library that's written in C++ that I'd like to use in my project, but I'd like to compile it directly into the executable and gain the benefits of smart-linking and of not having to rely on an external DLL, could I do that?

Mason

arthurprs
10-10-2007, 09:15 PM
I think it can't be done :?

Parcel
11-10-2007, 03:28 AM
function TExCrate: TDelphi; stdcall; external 'C++Builder';


I heard there is special external reference string 'C++Builder'.

example code
http://www.mediafire.com/?3hczvvkcshd

WILL
11-10-2007, 07:18 AM
Yeah, Borland already did this with it's older versions of the development studio. First with Kylix 2 and/or 3 (I know 3 had it, but unsure of it started wth 2 or not) then somewhere after doing that with Kylix they thought a 'do everything, super suite' under the title Delphi was such a wonderful idea they had to try to mix the two languages into one tool.

Unfortunately it turned out to be less productive than originally visioned/advertised (as I always understood the idea; you could code some forms with OP and others with C++ and it would somehow allow C++ and Object Pascal coders to work together on the exact same application. Interesting idea in theory.)

I forget which versions of Delphi actually allow you to compile C++ code, but I know Delphi 7 has combined documentation for both the Object Pascal and C++ function syntax.

jdarling
11-10-2007, 12:34 PM
Well, considering that the only difference in the early versions of Delphi and C Builder was the tokenizer you could easily switch between languages from Delphi 2 to Delphi 7. When they performed the full migration to .NET (remember D7 could build .NET compatible applications but was not a .NET compiler in any sense of the word) in Delphi8+ this "feature" was lost within the actual compiler itself.

The thing is, you don't need Delphi to do this if your using the .NET platform. You can simply bind the C/C++, C#, VB.NET, etc... extensions directly within your code. Just include the namespace and go. Of course, the problem in most cases is that the older C/C++ code won't build under the new .NET platform without a few minor tweaks.

marcov
09-09-2008, 02:14 PM
The thing is, you don't need Delphi to do this if your using the .NET platform. You can simply bind the C/C++, C#, VB.NET, etc... extensions


How is this possible? How does .NET know what C++ compiler I use?

JernejL
09-09-2008, 04:08 PM
step 1: compile c++ code into ".obj" files
step 2: link it into the delphi app directly.
step 3: profit!

marcov
29-10-2008, 08:58 AM
[quote="masonwheeler"]I read somewhere that Borland C++ Builder comes with the Delphi compiler included, allowing developers to use Object Pascal code in their C++ Builder projects. Does it work the other way too? If there's a library that's written in C++ that I'd like to use in my project, but I'd like to compile it directly into the executable and gain the benefits of smart-]

Afaik, yes, but only BCB in exactly the corresponding version (so not any C++ or even any BCB), and only when the C++ is specially crafted so that the interface doesn't use elements Delphi doesn't know (templates, operators maybe) and the classes are marked with the pureclass directive.

Which often for non trivial cases means: No. (since rework is too complicated and/or creates a separate codebase)

IIRC Rudy Velthuis homepage had some info on how to do this.