Prev Next

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
Swig Example: C++ Function Specifications

Prototypes

int         factorial_by_value(int n);
const char* message_of_void();
void        add_by_ptr(int x, int y, int* result);
int         max_array_by_ptr(int n, const int* x);
double      max_std_vector_double(const std::vector<double>& x);
const char* raise_exception(const char* message);

factorial_by_value
The return value is the factorial of the argument n .

message_of_void
The return value is the text OK.

add_by_ptr
The input value of result does not matter. Upon return result = x + y .

max_array_by_ptr
The array x has length n and the return value is the maximum of the elements of x .

max_std_vector_double
The return value is the maximum of the elements of x .

raise_exception
It message is the empty C string, the return value is the string corresponding to the previous call to raise_exception when message was non-empty. If message is non-empty, the message is store, so it can be retrieved later, and the following exception is thrown:
     std::runtime_error( std::string( 
message ) );
The message storage is done using a static variable and hence is not thread safe.

Contents
swig_xam_function.cppSwig Example: C++ Function Implementation

Input File: swig_xam/swig_xam.hpp