Hello Rob,

It's amazing. You are right: if I put ULONG just after the function declaration like this:
void StartupTapi (HINSTANCE hInstance) {
   ULONG ret;
   apiVersion = 0x30000;
   ...

It's ok. But if I shift the variable only 1 line down:
void StartupTapi (HINSTANCE hInstance) {
   apiVersion = 0x30000;
   ULONG ret;
   ...

It complains of 'error C2275: 'ULONG' : illegal use of this type as an expression'

Is that a MSVC issue, or more to do with inline.pm?

To be honest, I have no idea what FAR PASCAL means too. I'm trying very very hard to port some old sample codes into Perl (the C++ Guy left).

Thanks. Will keep you updated.

Sisyphus wrote:

----- Original Message ----- From: "Foo Ji-Haw" <[EMAIL PROTECTED]>
To: "Sisyphus" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Tuesday, February 21, 2006 5:42 PM
Subject: Re: Tough qn: understanding this (C) error while using inline


Hello guys,

Loading the library helped. I think I've hit the problem you foresaw.
ULONG returns an error during compilation:
error C2275: 'ULONG' : illegal use of this type as an expression


That's just because you need to declare *all* variables before any function
calls. The script that you attached should compile ok if you rewrite the
'StartupTapi' function as:

void StartupTapi (HINSTANCE hInstance) {
   //apiVersion = 0x20000;
   ULONG ret;
   apiVersion = 0x30000;
   ZeroMemory (&lip,sizeof (LINEINITIALIZEEXPARAMS));
   lip.dwTotalSize = sizeof (LINEINITIALIZEEXPARAMS);
   lip.dwOptions = LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;
   // orig line:

   // ULONG ret =
lineInitializeEx(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&a
piVersion,&lip);
   //
lineInitializeEx(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&a
piVersion,&lip);
} //StartupTapi

(Actually, since the 'ret' variable is not used, there is no need to declare
it at all.)

However, neither StartupTapi() nor tapilineCallbackFunc() will be accessible
to perl because of the HINSTANCE and DWORD arguments they receive. As I
demonstrated earlier, you need to pass those arguments as either SV*'s or
unsigned longs/ints, and then convert them to HINSTANCE/DWORD types from
inside the function. You also need to remove the "FAR PASCAL" from the
script .... I don't know what that means, and neither does perl :-)

If you run that script with the '-w' switch on, you'll get a warning about
the absence of functions accessible to perl:

Warning. No Inline C functions bound to Perl
Check your C function definition(s) for Inline compatibility

Cheers,
Rob


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to