t3x.org / t3x / t3x-manual / 2A3.html
 
T3X - A Minimum Procedural Language
Version 8.1.5, Online Edition
Copyright(C) 1996-2004
Nils M Holm
 
Previous:
2.10.2 Calling Interface Procedures
TOC | Index | Back Next:
2.11 Scoping Rules

2.10.3 A Sample Interface

The HELLO method used in the previos subsection could be implemented as follows:

/* world_code.c */
#include <txx.h>
#include <string.h>

int world_hello S2(char *s, XCELL n) {
        while (n--)
                write(1, s, strlen(s));
        return 0;
}

The name of the procedure implementing the interface procedure is a combination of the name of the file containing the procedure (without any suffixes), an underscore, and the name of the interface procedure:

fileName_interfaceName

The proper arguments to compile this code to an extension object depends on the host environment. However, the following requirements must be met:

To compile the above interface code to an extension object on a generic Unix system, a command like this may be used:

cc -o world_code.o -I /usr/local/include -DLIBRARY -c world_code.c

When compiling an object to be linked against TXX, -DLIBRARY should be omitted.

Previous:
2.10.2 Calling Interface Procedures
TOC | Index | Back Next:
2.11 Scoping Rules