next up previous contents
Next: Examples Up: Function aliasing Previous: Providing a Function   Contents

Conventions and Restrictions

Various restrictions are necessary to make function aliasing work. These are

  • The return type of any function must be either void or one of the Cactus data types CCTK_INT or CCTK_REAL. Standard types such as int are not allowed.
  • The type of an argument must be one of scalar types CCTK_INT, CCTK_REAL, CCTK_COMPLEX, CCTK_STRING, CCTK_POINTER, CCTK_FPOINTER, or an array or pointer type CCTK_INT ARRAY, CCTK_REAL ARRAY, CCTK_COMPLEX ARRAY, CCTK_POINTER ARRAY.part141 The scalar types are assumed to be not modifiable. Any changes made to a scalar argument by a providing function may be silently lost, or may not; it is dependent on the language of the providing and calling function. If you wish to modify an argument, then it must have intent OUT or INOUT (and hence must be either a CCTK_INT, a CCTK_REAL, or a CCTK_COMPLEX, or an array of one of these types).
  • The name of both, the aliased and providing function, are restricted. They must follow the standard C semantics (start with a letter, contain only letters, numbers or underscores). Additionally, they must be mixed case (that is, contain at least one uppercase and one lowercase letter). The names of the aliased and providing functions must be distinct.
  • If an argument is a function pointer, then the syntax looks like
    CCTK_REAL Integrate(CCTK_REAL CCTK_FPOINTER  func(CCTK_REAL IN x), \
                        CCTK_REAL IN xmin, CCTK_REAL IN xmax)
    
    It is assumed that the function pointer argument has the same language as the calling function. Function pointer arguments may not be nested.
  • CCTK_STRING arguments follow the same conventions as in the previous section. That is, they must appear at the end of the argument list, there must be at most three, and a function with a CCTK_STRING argument can only be provided in C, not Fortran, although they may be called from either.


next up previous contents
Next: Examples Up: Function aliasing Previous: Providing a Function   Contents