REFERENCE_PARAM()?

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
fas
Member
Posts: 12
Joined: Wed Aug 03, 2016 11:59 pm

REFERENCE_PARAM()?

Post by fas »

Where is this defined? What is the purpose? It is not documented anywhere that we can find?


srinie
XCore Addict
Posts: 158
Joined: Thu Mar 20, 2014 8:04 am

Post 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.
robertxmos
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Post 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.
goodfeather
Member++
Posts: 23
Joined: Wed Mar 30, 2016 11:10 am

Post 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
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post 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
Post Reply