Including extensions

I can’t seem to get an extension included in my build.

I have created a file at …/Documents/TADS 3/Extensions/myfile.t

I have set …/Documents/TADS 3/Extensions/ as my Extensions folder in the System options.

I put “#include <myfile.t>” in my main game .t file.

The compiler says it can’t find myfile.t. What have I missed?

You should probably look on the .tl files which are used to define extension and I’d like to warn you about #include - it is mainly intended to include header files (.h), not another source (*.t) which normally should not be placed inside another source file but compiled separately and linked aftewards into resulting binary (lot like in C languages). See

Are you using Workbench in Windows, or are you developing in some other manner? If so, you want to put the extension in the Include Files folder in the Project pane.

I tried to figure out what to do from reading the Compiling and Linking documentation, but I still don’t really know what to do.

Let’s say I want the file to be used in not just one project, but as an addition to any project. I should save this as a .tl file? And then put it where, and reference it how? Baby steps here, as I honestly have no idea what to do from reading the linked documentation page. Is there documentation with examples?

If you take a look at the existing .tl files, you should figure out what’s going on. for example:

[code]name: TADS System Files
source: _main
source: file
source: tok
source: gramprod
source: multmeth

we explicitly include the main startup module, so we don’t want the

compiler to include it automatically

So simply replicate that. For example, create a file “” and put this in it:

name: My Awesome Extension source: mysourcecode
The .t suffix is optional in the “source:” files. But you could have used “source: mysourcecode.t” just as well. And if your extension consists of several source files, then add more “source:” entries. Do NOT list header files (".h") there. Only .t files.

To keep the extension separated from other libraries, you can put it in its own directory. For example “Documents/TADS 3/Extensions/myextension”. And in that directory, you’d put “”, “mysourcecode.t” and any header files you might have.

Now you can add this extension to any project you want the same you add any other library. For example, if your project currently uses this in its makefile:

-lib -lib adv3/
then simply add “-lib extensions/” to it:

-lib -lib adv3/ -lib extensions/

Thank you! I see that that was in the Compiling and Linking documentation, but I wasn’t able to piece out what I needed… you extracted and made sense of the necessary bits, thanks again.

I have a remaining question though, about #include… so, this needs to be done on each source file? This isn’t project-wide? What I mean is, I got the extension working based on your instructions above, but the code then in my source file was throwing a compiler error on a standard piece of code from the main includes. In this case “rand()”, wasn’t defined. I included tads.h directly into my extensions source file, and now it works. This file was already included before in the project in libraries loaded before it, so I just want to make sure this is correct, that each file needs to independently include headers it uses code from?

Header files must be included in every source file that needs something from that header. Header files only contain declarations and macros, not definitions, which means that they actually don’t generate any code.

For example, when you define a class in a source file, that class is getting compiled and is visible from any other part of the code. On the other hand, an intrinsic function declaration or macro from a header file is not compiled into code, and thus is not visible from code in different files.

This is the reason why you shouldn’t put anything in header files that actually generates compiled code. For example, if you put a class definition in a header file, and then include that header in two source files, the class will be defined twice, which is an error. This is also why you shouldn’t #include *.t files.