Skip to content

Error reporting (errno.h)

Include errno.h for the runtime error indicator and numeric error codes.

Variables and Macros

Name Meaning
errno Global error indicator for the single-threaded dcc runtime.
EPERM Operation not permitted.
ENOENT No such file or directory.
ESRCH No such process.
EINTR Interrupted function call.
EIO Input/output error.
ENXIO No such device or address.
E2BIG Argument list too long.
ENOEXEC Executable file format error.
EBADF Bad file descriptor.
ECHILD No child processes.
EAGAIN Resource temporarily unavailable.
ENOMEM Not enough memory.
EACCES Permission denied.
EFAULT Bad address.
EBUSY Device or resource busy.
EEXIST File exists.
EXDEV Cross-device link.
ENODEV No such device.
ENOTDIR Not a directory.
EISDIR Is a directory.
EINVAL Invalid argument.
ENFILE Too many files open in system.
EMFILE Too many open files.
ENOTTY Inappropriate I/O control operation.
EFBIG File too large.
ENOSPC No space left on device.
ESPIPE Invalid seek.
EROFS Read-only file system.
EMLINK Too many links.
EPIPE Broken pipe.
EDOM Domain error.
ERANGE Result too large or out of range.
ENOTEMPTY Directory not empty.

Runtime model

The DCC C Compiler runtime is single-threaded, so errno is one global int. Runtime calls set it when they fail; successful calls are not required to clear it. Test the function result first, then inspect errno only on failure.

C89 requires EDOM and ERANGE. DCC C Compiler also defines conventional small-system and POSIX-style file errors used by the CP/M file and directory support.

Error checks

#include <errno.h>
#include <stdio.h>

FILE *fp = fopen("DATA.TXT", "r");
if (!fp) {
    if (errno == ENOENT)
        puts("missing file");
    else
        printf("open failed: %d\n", errno);
}

Use strerror(errno) from string.h or perror from stdio.h when you want runtime text for an error code.