Exercise 0: Set up your workbench¶
Aim: edit a file, run it and build a native executable. No previous terminal experience is assumed. An editor changes a file; a terminal runs commands.
Prepare¶
Follow installation and platform setup.
Keep the unpacked bin/ and share/ directories together. Confirm the compiler
is available with fibc --version. Building needs the platform's C compiler,
cc; the release includes LLVM, so you need no LLVM installation for this course.
Create a directory for your work and enter it:
mkdir creates a directory, cd changes the shell's current directory and pwd
prints it. Your editor must save files in this same directory. Use plain text,
not a word processor, and save the following as ex00.fib.
Type and predict¶
Check your prediction
fibc run prints:
./ex00 prints only workbench ready. The ./ asks the shell to run a file in
the current directory. Its exit status is zero; echo $? immediately afterward
prints 0. The compiler's run command prints main's result; the executable
passes it to the shell as a status.
Run these commands after typing the program, before uncovering the answer above:
Change it¶
- Change the message to your name. Run the file, then rebuild and run
./ex00. - Change main's last value to
7. Predict both runs and the native exit status. - Restore
0. Make a second fileex00-again.fibby typing from memory.
Break and repair¶
Save a copy as ex00-broken.fib. Remove one closing parenthesis. Run it and
record the first diagnostic. Restore the parenthesis and run again. Do not
rebuild the original executable until you can explain which file you changed.
Checkpoint¶
- Show that your editor and terminal use the same directory.
- Explain why editing
ex00.fibdoes not change an already-built./ex00. - Explain the extra
0fromfibc runwithout calling it your printed message.