Jump to content


Photo

Creating a DLL, getting "Unexpected Error"


  • Please log in to reply
2 replies to this topic

#1 lukeescude

lukeescude

    GMC Member

  • GMC Member
  • 514 posts
  • Version:GM:Studio

Posted 04 January 2012 - 12:46 AM

Hey all, need some help, getting some "unexpected error" during the game

Here's how I'm exporting all my functions:
#define USBRADIO_API extern "C" __declspec(dllexport)
//Functions
USBRADIO_API bool HWInit();
USBRADIO_API bool HWDeInit();
USBRADIO_API bool FMTune (long frequency);
...

Which is typical, right?

here are some of the actual function definitions:
USBRADIO_API bool
HWInit ()
{
	bool ret = OpenFMRadio(&fmRadioDevice);
	return (ret);
}

USBRADIO_API bool
HWDeInit ()
{
	CloseFMRadio(&fmRadioDevice);

	return true;

}

USBRADIO_API void 
TuneFreq (long frequency)
{
	fmRadioDevice.Tune((double)frequency/1000);
}

Edited by lukeescude, 04 January 2012 - 01:10 AM.

  • 0

#2 Medusar

Medusar

    GMC Member

  • GMC Member
  • 1228 posts
  • Version:GM:Studio

Posted 04 January 2012 - 09:31 AM

You can only return doubles for real numbers and char*s (null-terminated char arrays) for strings to GM. GM doesn't accept bools, ints, or any other type of data. Also, GM only passes these types of data to the DLL. You'll have to return 1.0 or 0.0 instead of true or false for boolean returns.
  • 0

#3 lukeescude

lukeescude

    GMC Member

  • GMC Member
  • 514 posts
  • Version:GM:Studio

Posted 04 January 2012 - 11:25 PM

Yes, someone from the other thread came up with that and it fixed the issue.

Thanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users