pointer?

M

Michael Sgier

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
 
M

maverik

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?
 
M

maverik


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 *
 
F

Fred

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."
 
M

Michael Sgier

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

Jorgen Grahn

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
 
M

maverik

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,078
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top