Re: Convert C-Builder program to Delphi?

From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 01/27/05


Date: Thu, 27 Jan 2005 14:56:02 +0100


"W. D." <NewsGroups@US-Webmasters.com> wrote in message
news:41F8884A.539E@US-Webmasters.com...

> [...] Right now this C++ code that I am working on is getting
> bizzare. As far as I can tell, the following code is for
> compatibilty with DLLs.
>
> I Googled just about everyplace I can think of and still
> haven't come up with the proper way to translate these
> to Delphi:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> #if !defined (DLLFUNC)
> #define DLLFUNC(ret) extern __declspec(dllexport) ret __stdcall
> #endif
>
> DLLFUNC(int) SomeDLL_Open();

DLLFUNC(T) more or less wraps type T so that declaring a function
to return it is also usefully exported from a DLL this source is
linked into.

It is a macro and depends on C preprocessor macros being textual;
also on the syntactical closeness of the relevant C keywords.
Delphi does not have them all next to each other and doesn't have
macros anyway.

Marking functions as exported is done in the project file in Delphi,
quite separate from the function declaration itself. The calling
convention is given by a directive added after the declaration but
it marks up the declaration as a whole, not just the type. (That's
true also for C, but macros don't care.)

Look for "exports" and "stdcall" in the help.

Groetjes,
Maarten Wiltink



Relevant Pages

  • Re: Convert C-Builder program to Delphi?
    ... > compatibilty with DLLs. ... It is a macro and depends on C preprocessor macros being textual; ... Delphi does not have them all next to each other and doesn't have ... quite separate from the function declaration itself. ...
    (comp.lang.cpp)
  • Re: Bob Flannagan
    ... Nathan, ... declaration takes precedent over global declarations. ... what is telling you that it is reset? ... Productivity add-ins and downloadable books on VB macros for Excel ...
    (microsoft.public.excel.programming)
  • Re: Object reference not set to an instance of an object
    ... The error is almost certainly in your code, not in any of those DLLs. ... ArrayList foo; ... run into where it even makes sense to separate the declaration of the ... triggering the exception that way. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SafeArrayTypeMismatchException
    ... There is a function in one of my dlls whose signature is as follows: ... Declaration for my Function is as follows: ... As Integer, ByVal Z As String, AAs String, AAs Integer) As ... ReDim la_accessAs Integer ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Macro file organization
    ... One good reason for multi-modules is variable declaration: ... Another advantage of multi-modules is it allows you to organize your macros ... convenience that saves searching and scrolling within a module. ...
    (microsoft.public.excel.programming)