CDEFS(3)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’– CDEFS(3) πŸ’–

okay so this is from the Library Functions Manual bestie, buckle up πŸŽ€

✨ NAME ✨

cdefs β€” common definitions and macros, aka the little header that runs the whole friend group πŸ’…

✨ SYNOPSIS ✨

#include <sys/cdefs.h>

✨ DESCRIPTION ✨

So the <sys/cdefs.h> header is literally carrying some common definitions and macros that are, like, typical to the C language conventions of NetBSD. no cap. Among these are:

  • Certain C language properties and definitions that get versioned according to what the compilers actually support πŸ¦‹ β€” examples include the __func__ keyword and the restrict type qualifier from C99. iconic behaviour tbh.
  • Macros and definitions that are specific to compilers, preprocessors, and linkers πŸ‘‘ β€” go look at __BIT(3), __BITS(3), __CONCAT(3), __FPTRCAST(3), __SHIFTIN(3), __SHIFTOUT(3), __SHIFTOUT_MASK(3), __UNCONST(3), __UNVOLATILE(3), __USE(3), __insn_barrier(3), and attribute(3). that's a whole squad fr fr.
  • Utility macros provided purely for convenience πŸ’– β€” see __arraycount(3) and bits(3). they're just being nice to you.

The header also contains the __RCSID() and __KERNEL_RCSID() macros, which are used for version control system (VCS) identifiers πŸ“Œ. The way that works: all NetBSD source code files typically include <sys/cdefs.h>, and they include it as the first thing right after any possible copyright texts. like, first in line, main character energy ⭐

/*-
 * Copyright (c) 1984 John Doe
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms,
 * with or without modification, are permitted.
 */

#include <sys/cdefs.h>
__RCSID("$NetBSD: cdefs.3,v 1.5 2019/11/10 18:45:09 christos Exp $");

And yeah β€” it is possible to identify the RCS keyword strings by using ident(1) πŸ” iykyk.


✨ SEE ALSO ✨

ident(1), param(3), stddef(3), types(3), c(7) 🫢 go read them, they're all in the group chat.

✨ HISTORY ✨

The <sys/cdefs.h> header was originally imported from 386BSD 🧚 giving ancestral legend, honestly.


k that's the whole page bestie πŸ’œ this cutie dropped from Debian on November 10, 2019. go forth and #include responsibly 🌈

πŸ“¦ where this page comes from