Interface with C
ana
ana@ufu.br
Fri, 29 May 1998 19:26:05 +0000
I was happy to notice that the Clean team addressed my suggestion of
providing the language with an interface with C, and with a better path
manager. Now, Clean 1.3 has default paths to StdEnv and to IOInterface.
That makes life much easier for beginers. The interface to C is very
cool too. All you need to do is to add C object modules in the
link options. I would say that Clean team fulfiled all my wishes.
Now, I hope that they will keep the language simple and easy to
use. This will put Clean within reach of people who, like myself,
are not computer scientists.
Another thing. I need some help of you people who already played around
with the new C interface. I am using windows 95. I tryed to link
this very small C program with Clean:
int fn(int x, int y) {
return(x*x+y*y);}
Everything worked fine. Then, I tryed a more substantial task. In few
words, I tryed to add the program below to a Clean application. Since
the program requires the library Winmm.lib, I used the link options
to add it as well. Clean compiled the application and generated
an executable file. However, the file didn't execute. It complained
that there were a DLL missing (ARCH.DLL). I never heard about that
DLL. In fact, I couldn't find it in the system. By the way, I use
this C program and the Winmm.lib in my Visual Prolog applications,
and I never had any problem with a missing DLL.
#include <windows.h>
#include <mmsystem.h>
wav(LPSTR path, int *som, HWND win)
{
MCI_OPEN_PARMS mciOpen;
MCI_PLAY_PARMS mciPlay;
unsigned long rtrn;
int soundID= -1;
mciOpen.wDeviceID=NULL;
mciOpen.lpstrDeviceType="waveaudio";
mciOpen.lpstrElementName=path;
if((rtrn=mciSendCommand(NULL,MCI_OPEN,MCI_OPEN_TYPE |
MCI_OPEN_ELEMENT,(DWORD)(LPVOID)&mciOpen)) != 0L)
return(1);
soundID=mciOpen.wDeviceID;
*som= soundID;
mciPlay.dwCallback= win;
if((rtrn=mciSendCommand(soundID,MCI_PLAY,
MCI_NOTIFY,(DWORD)(LPVOID)&mciPlay)) != 0L) {
mciSendCommand(soundID,MCI_CLOSE,0,NULL);
return(1);
}
return(1);
}
closemm(int soundID)
{
if (soundID != -1) mciSendCommand(soundID,MCI_CLOSE,0,NULL);
return 1;
}