Next Previous Contents

10. Command Line Reference


Mandate that input headers be interpreted as C++, which can be helpful to coerce the interpretation of files that either lack a .hh suffix or do not contain class definitions or other explicit C++ syntax.


Generate standalone C wrappers (.cc and .h files) from the headers of a C++ library, enabling it to be called from C scope but not S-Lang proper.


Directs SLIRP to interpret functions with 'char*' return values as though they were actually 'const char*' instead. Without the aid of hints like 'const' SLIRP has no way of ascertaining if the function being wrapped returns a string which must be freed by the caller to avoid a memory leak. Since newer libraries that are carefully written tend to make judicious use of the 'const' qualifier, SLIRP takes the position that if 'const' is missing then a call to free() is required after pushing char* instances onto the stack. The -const_strings switch turns that behavior off, but may result in memory leaks within your module.


Include slirp_debug_pause() debugging stub within module.

-fprefix function_prefix

Directs SLIRP to generate wrapper functions only for those functions with names that begin with an exact match of function_prefix. This can be useful in situations when SLIRP either generates too many functions or two few, perhaps because it cannot distinguish between private and public functions in the api being wrapped. By default SLIRP attempts to generate code for any function whose name matches the regular expression "^[a-zA-Z]+".


Directs SLIRP to print debugging information during code generation.

-ignore option

Tune the emission of ignored symbol messages: use notrunc to append to existing ignored symbol list (default: the ignored symbol list is truncated at startup), or specify an alternate output file name (default: ./ignored.txt)

-I directory

Specify directory to search for headers during code generation. Each -I opton is automatically propagated to make files generated by -make, as is any path prefix included in the specification of any input header file.

-L directory

Specify directory to search, within emitted make file, at link time. Use of this option implicitly turns on -make.

-l lib

Specify the short-form name (consult your linker documentation) of a library to pull in, within emitted make file, at link time. Use of this option implicitly turns on -make.

-ldflags flags

Specify additional flags to pass to the linker within emitted make file. May also be used as an alternative to -L or -l. To specify multiple linker flags with a single -ldflags option, separate them with whitespace and enclose within single- or double-quotes. Use of this option implicitly turns on -make.

-m module_name

Emit generated code to files whose names begin with module_name, instead of the default (which uses the stem of the first input file that is processed).


Emit a make file that can be used to automate compilation of the module. The content of the generated file can be tuned by use of the -I, -L, -l, and -ldflags options.

-mapnames regular_expression replacement

Deprecated synonym for -rename


By default SLIRP will automatically map unknown types (i.e. types which have no entry in the SLIRP typemap table) to void_ptr. This tactic permits larger portions of libraries to be wrapped automatically, and with less interface file writing. This switch should be employed when this behavior is not desired, with the effect that SLIRP will not emit wrapper code for any function whose signature contains unknown types.


Do not generate a module initialization fragment.


Whenever possible, do not generate code to explicitly pop arguments from the S-Lang stack into local variables within the wrapper. For instance, using -nopop during the generation of the kitchensink module above would yield a ksink_mult wrapper which looks like
        static void sl_ksink_mult (double* arg1, double* arg2)
           double result;
           result = ksink_mult(*arg1, *arg2);
           (void) SLang_push_double ( result);
Using this option will thus shrink the size of generated code and may boost runtime performance slightly, but at the expense of other features like the automatic generation of Usage: statements when an incorrect number of arguments are passed to the function. Note even when -nopop is specified there may be instances when SLIRP has no choice but to explicitly pop arguments from the stack; these conditions are enumerated within the internal source code documentation.


Emit a hierarchical list of all opaque types defined by the current invocation, then exit. The former name of this option was -l.


Emit OpenMP #pragmas to parallelize vectorized code. This option implies -vec, i.e. it turns on vectorization.


Print the interface for code which would be generated, but don't actually generate it.

-rc file

Load SLIRP customizations from file, rather than from the first instance found within $PWD/slirprc or the $SLIRPRC environment variable.


Permit S-Lang scalars to be passed to C functions expecting arrays, or Fortran functions (which passes all arguments by reference), by popping them off the stack as 1-element arrays. By default this behavior is on for bindings to Fortran codes, and off for bindings to C codes. Note that this does not provide a way of modifying scalar variable values absent the use of the S-Lang reference operator (&), as the original scalar is effectively read-only in the glue layer.

-rename regular_expression replacement

Directs SLIRP to map C function names matching the given regular_expression to S-Lang function names beginning with replacement. Suppose, for example, that
        slirp -mapnames ksink_ yada_ ksink.h
were specified during the generation of the kitchensink module in the opening chapter. Then the do_mult() sample function would need to reflect such
        define do_mult(op1, op2)
           () = printf("ksink_mult(%S,%S) = %S\n",
                                op1, op2, yada_mult(op1, op2));
This option may be specified multiple times at invocation, using any regular expression suitable for the S-Lang string_match() function. Consult the Regular Expressions chapter within the S-Lang language guide for more details.


Cause generated code to be emitted to stdout instead of a named file.


Generate source code for the interface specified as input to SLIRP, as a set of empty (stub) functions. This supports exercising the module interface without the need to link in the underlying library or any of its (potentially numerous) dependencies.

-tmapout file

Save a copy of the type mappings table (generated during the first pass SLIRP makes over its input header files) to the given file, as a series of SLIRP commands that can executed by the S-Lang interpreter to recreate the typemap table.

-tmapin file

Load, using evalfile(), additional typemaps from the given file, which was presumably created by a -tmapout switch from a previous invocation of SLIRP.}


Show verbose messages when loading S-Lang scripts


Attempt to vectorize every function within input interface


Output the SLIRP version.

Next Previous Contents