realbasic-nug
[Top] [All Lists]

Re: Returning a string from a c dll to real basic

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Returning a string from a c dll to real basic
From: Alberto Paderno <alberto dot paderno at avpnet dot org>
Date: Wed, 31 Aug 2005 12:15:53 +0200
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <00a801c5ae02$377fb0d0$0100000a at KEITHXP> <A7DDAFA5-8652-4FA8-8EF4-93D7F8372135 at mac dot com> <00b901c5ae05$985f2950$0100000a at KEITHXP>
Keith Hutchison wrote:

Is this a correct way to send back a string from c ?
export char* _stdcall getCurrentRecordingDevice()
{
char    deviceName[MIXER_SHORT_NAME_CHARS] = "null";
/*
  processing to get name works.
*/
return deviceName ;
Don't you return a function local variable, which get's
released just after return from the function?
Isn't deviceName a local variable?

Keith
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>




Surely it is, but it will be allocated on the stack, that outside the function scope will get any other values, and for sure it will not be a value you can interprete as a string (if not for a fortunate coincidence). It would be different if you declared the variable to be static: in that case it would exist also outside the function scope.


Best Regards.
--
Alberto Paderno
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>