I am trying to use a Delphi function in a C++ Builder project (because ImageEn's IEVision component does not have a C++ Interface that works to extract the barcodes yet, so I need to extract the barcodes in a Delphi unit)
I create a C++ Builder project, and add a Delphi Unit, whose complete code is:
unit Unit2;
interface
implementation
function MyOutput : String ;
begin
Result := 'hello';
end;
end.
I use that unit in my C++ form:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String result = MyOutput();
}
The generated .hpp is:
// CodeGear C++Builder
// Copyright (c) 1995, 2013 by Embarcadero Technologies, Inc.
// All rights reserved
// (DO NOT EDIT: machine generated header) 'Unit2.pas' rev: 26.00 (Windows)
#ifndef Unit2HPP
#define Unit2HPP
#pragma delphiheader begin
#pragma option push
#pragma option -w- // All warnings off
#pragma option -Vx // Zero-length empty class member
#pragma pack(push,8)
#include <System.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Unit2
{
//-- type declarations -------------------------------------------------------
//-- var, const, procedure ---------------------------------------------------
} /* namespace Unit2 */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_UNIT2)
using namespace Unit2;
#endif
#pragma pack(pop)
#pragma option pop
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // Unit2HPP
Notice that the declaration of the MyOutput function is not included in the .hpp file. How do I get Delphi to put that function into the .hpp