[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

pointer?

Michael Sgier

11/21/2008 2:17:00 PM

Hi
Declaration:

XPLM_API XPLMDataRef XPLMFindDataRef(
const char * inDataRefName);

Does this return a pointer?

So I try this:

XPLMDataRef gPlaneV = NULL;

gPlaneV = XPLMFindDataRef("sim/graphics/view/view_type");

if (XPLMGetDatai(gPlaneV) != 1026)
XPLMSetDatai(gPlaneV, 1026);


But this doesn't work. If the declaration returns a pointer so how can I
set it's value ( integer ) to 1026?
Many thanks and regards
Michael

8 Answers

maverik

11/21/2008 2:35:00 PM

0

On Nov 21, 5:16 pm, Michael Sgier <sg...@nospam.com> wrote:
> Hi
> Declaration:
>
> XPLM_API XPLMDataRef          XPLMFindDataRef(
>                                     const char *         inDataRefName);
>
> Does this return a pointer?

Sorry, I doesn't have libastral in my OS distribution. Can you provide
defenition of the type XPLMFindDataRef?

maverik

11/21/2008 2:39:00 PM

0

On Nov 21, 5:35 pm, maverik <maverik.m...@gmail.com> wrote:
> defenition of the type XPLMFindDataRef?

: D defInition

Michael Sgier

11/21/2008 2:49:00 PM

0

maverik

11/21/2008 3:00:00 PM

0

On Nov 21, 5:49 pm, Michael Sgier <sg...@nospam.com> wrote:
> Hi
> that's all I have:
>
> http://www.xsquawkbox.net/xpsdk/phpwiki/index.php?XPLM...

From the link:

typedef void * XPLMDataRef;

So,

> XPLM_API XPLMDataRef XPLMFindDataRef(const char *inDataRefName);
> Does this return a pointer?

Yes.

Accroding to 7.3.1.p1 of the ISO/IEC C++ Standard (2003)

Within the scope of its declaration,
a typedef-name is syntactically equivalent to a keyword and names the
type associated with the identifier in the way described in clause 8.
A typedef-name is thus a synonym for another type. A typedef-name
does
not introduce a new type the way a class declaration (9.1) or enum
declaration does.

So you can think of XPLMDataRef as a synonym for void *

Fred

11/21/2008 7:24:00 PM

0

On Nov 21, 6:16 am, Michael Sgier <sg...@nospam.com> wrote:
> Hi
> Declaration:
>
> XPLM_API XPLMDataRef          XPLMFindDataRef(
>                                     const char *         inDataRefName);
>
> Does this return a pointer?
>
> So I try this:
>
> XPLMDataRef             gPlaneV = NULL;
>
> gPlaneV = XPLMFindDataRef("sim/graphics/view/view_type");
>
> if (XPLMGetDatai(gPlaneV) != 1026)
>         XPLMSetDatai(gPlaneV, 1026);
>
> But this doesn't work. If the declaration returns a pointer so how can I
> set it's value ( integer ) to 1026?

What do you mean by "it doesn't work" ?
Does the code fail to compile? If so, what is the error message?

If it does compile, does it crash? If so, what error message?

If it runs, how do you know it doesn't work?

Read the documentation, which includes:
"Write a new value to an integer data ref. This routine is a no-op if
the plugin publishing the dataref is disabled, the dataref is invalid,
or the dataref is not writable."

--
Fred Kleinschmidt


Michael Sgier

11/22/2008 6:13:00 AM

0

Hi Fred
it compiles fine. When I watch gPlaneV, XPLMFindDataRef returns a hex
or something alike. How shall I use gPlaneV?
Thanks indeed
Michael

Jorgen Grahn

11/22/2008 10:35:00 PM

0

On Sat, 22 Nov 2008 07:13:26 +0100, Michael Sgier <sgier@nospam.com> wrote:
> Hi Fred
> it compiles fine. When I watch gPlaneV, XPLMFindDataRef returns a hex
> or something alike. How shall I use gPlaneV?

Based on info elsewhere in the thread, gPlaneV is really a void *.
Probably it's used as an opaque handle, meaning you're only supposed
to pass it to other API functions. It's like FILE * in the standard
library.

Side note: this is a C API, so most people here will not be too
interested in it. It looks primitive to me (and what's the deal with
"XPLM_API" and all the "inFoo" names? Weird.)

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!

maverik

11/24/2008 10:20:00 AM

0

On Nov 23, 1:35 am, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:

> Based on info elsewhere in the thread, gPlaneV is really a void *.
> Probably it's used as an opaque handle

Exactly.

> Side note: this is a C API, so most people here will not be too
> interested in it. It looks primitive to me (and what's the deal with
> "XPLM_API" and all the "inFoo" names? Weird.)

XPLM_API XPLMDataRef XPLMFindDataRef(const char *inDataRefName);

Looks like Win dll signature or something like that

It usually looks as follows:

#ifdef XPLM_EXPORTS
#define XPLM_API __declspec(dllexport)
#else
#define XPLM_API __declspec(dllimport)
#endif

May be Michael should write to the
comp.os.ms-windows.programmer.win32 or something like that.