Page 1 of 1

REFERENCE_PARAM()?

Posted: Mon Aug 29, 2016 6:58 pm
by fas
Where is this defined? What is the purpose? It is not documented anywhere that we can find?

Re: REFERENCE_PARAM()?

Posted: Mon Aug 29, 2016 7:35 pm
by srinie
Please refer to xccompat.h from the toolchain install folder::

#ifdef __XC__
#define REFERENCE_PARAM(type, name) type &name
#else
#define REFERENCE_PARAM(type, name) type *name
#endif


Useful for api defines when used across *.xc and *.c files.

Re: REFERENCE_PARAM()?

Posted: Tue Aug 30, 2016 9:51 am
by robertxmos
In XC you can pass by reference (as in c++).
In C you must pass by pointer.
Historically, XC did not offer pointers, hence the need for macro magic in header files used by both.
Post compilation, referecence and C-pointers are the same hence why it is safe to munge in this way.

Re: REFERENCE_PARAM()?

Posted: Fri Sep 02, 2016 6:24 am
by goodfeather
Dear Sir,
This description is also troubled me.
1.I am unable to find out where "__XC__" is defined.
2.or does it mean "__XC__ is defined" is default setting for .xc files ?

Thanks

#ifdef __XC__
#define REFERENCE_PARAM(type, name) type &name
#else
#define REFERENCE_PARAM(type, name) type *name
#endif

Re: REFERENCE_PARAM()?

Posted: Fri Sep 02, 2016 7:38 am
by infiniteimprobability
__XC__ gets set automatically when compiling.xc files. As srinie says, thus macro is useful when declaring and writing functions that need to be callable from xc or c