RSS YouTube LinkedIn Twitter XCore IRC

Search

Projects Tutorials Forum

Personal tools

Calling functions that have pointer arguments

From XCore Exchange

Jump to: navigation, search

If you have a C function that requires a pointer (such as one that access an array) you may want to call it from XC. As XC does not support pointers, some minor modifications will be needed for your header files.

An example function such as the one below needs to be called from XC:

void foo( char *bar, unsigned *n )
{
  /*... access array */
}

The following declaration should be made in the appropriate header file:

#ifdef __XC__
void foo( char bar[], unsigned &n );
#else
void foo( char *bar, unsigned *n );
#endif

This will then allow you to pass a char array and integer by reference.