> I trying to write a DLL from a Visual C specification and
> (not really knowing C
> much at all) I need a little help with some of the conversion:
>
> 1) I presume I can convert all the straighforward #Defines
> into consts?
Mostly yes, but bear in mind the C preprocessor will substitute anything
with a #define, not only consts - eg.
#define func1 AReallyLongFunctionName
func1(someparam);
gets translated to
AReallyLongFunctionName(someparam);
> 2) Can I convert the macro defines into functions? eg what would:
> #define AlphaByte(x) (((x))>>ALPHA_SHIFT)
> map to?
function AlphaByte (x: Integer): Integer;
begin
Result := x shr ALPHA_SHIFT;
end;
> 3) there is one particular conditional define that I am not
> sure about at all:
> #ifndef DLLEXPORT
> #define DLLEXPORT __declspec( dllexport )
> #endif
> then at the end of the header file there is:
> DLLEXPORT VisInfo* QueryModule(void); /* exported DLL */
> I understand that DLLEXPORT will be replaced with
> __declspec( dllexport ),
> but it's the only place so why bother defining it? And what
> does it do? and can
> I achieve the same thing in Delphi?
Basically, that defines the function as exportable in the DLL.
> 4) Can I ignore the #pragmas? There is only one (used in a
> couple of places):
> #pragma pack (push, 8) and #pragma pack (pop, 8)
This tells the compiler to use 8-byte packing for structures.
> 5) When compiling are there any special flags etc that I
> should use to ensure
> it's as compatible as possible with a Visual C compiler's output?
You will most probably need to use cdecl. I am not sure if the name
mangling algorithm that Delphi uses is the same as C++.
Dennis.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz