Next: , Up: Mixing C and Prolog   [Contents][Index]


6.1 Notes

The SP_PATH variable

It is normally not necessary, nor desirable, to set this system property (or environment variable), but its value will be used, as a fall-back, at runtime if it cannot be determined automatically during initialization of a runtime or development system. In this chapter, SP_PATH is used as a shorthand, as follows.

On Windows, SP_PATH is a shorthand for the SICStus Prolog installation directory, whose default location for SICStus 4.9.0 is C:\Program Files\SICStus Prolog VC16 4.9.0\.

On UNIX, the default installation directory for SICStus 4.9.0 is /usr/local/sicstus4.9.0/ and SP_PATH is a shorthand for the subdirectory lib/sicstus-4.9.0/ of the installation directory, e.g.: /usr/local/sicstus4.9.0/lib/sicstus-4.9.0/.

See System Properties and Environment Variables for more information.

Definitions and declarations

Type definitions and function declarations for the interface are found in the header file <sicstus/sicstus.h>.

Error Codes

The value of many support functions is a return code, namely: SP_SUCCESS for success, SP_FAILURE for failure, SP_ERROR if an error condition occurred, or if an uncaught exception was raised during a call from C to Prolog. If the value is SP_ERROR, then the macro SP_errno will return a value describing the error condition:

int SP_errno

The function SP_error_message() returns a pointer to the diagnostic message corresponding to a specified error number.

Wide Characters

The foreign interface supports wide characters. Whenever a sequence of possibly wide character codes is to be passed to or from a C function it is encoded as a sequence of bytes, using the UTF-8 encoding. Unless noted otherwise the encoded form is terminated by a NUL byte. This sequence of bytes will be called an encoded string, representing the given sequence of character codes. Note that it is a property of the UTF-8 encoding that it does not change ASCII character code sequences.

If a foreign function is specified to return an encoded string, then an exception will be raised if, on return to Prolog, the actual string is malformed (is not a valid sequence of UTF-8 encoded characters). The exception raised is error(representation_error(mis_encoded_string),representation_error(…,…,mis_encoded_string)).



Send feedback on this subject.