-
Book Overview & Buying
-
Table Of Contents
D Cookbook
By :
Linux system calls are typically performed via a C interface. D can call these just like any other C library functions (see the Using external libraries recipe in Chapter 1, Core Tasks). Here, we'll write a "Hello World" program using the standard C function for the system call, and say "hello" using inline assembly to demonstrate how that can be done as well.
Making Linux system calls with inline assembly is quite different than making them with the C interface. First, we will look at how it is done with the function, then we'll translate it to the assembly.
Let's make Linux system calls by executing the following steps:
Import the appropriate header from the core.sys.posix package, or if it is not present, write the prototype with extern(C).
Call the function like you would call any other function.
The code is as follows:
import core.sys.posix.unistd; // analogous to #include <unistd.h> string hello = "Hello, world!"; write(1 ...
Change the font size
Change margin width
Change background colour