This project provides a C header that enables more feature-rich compilation across various compilers and platforms. It also contains the basic documentation for mulle-c development. mulle-c11 is used by all mulle-c or mulle-objc projects.
Release Version | Release Notes |
---|---|
RELEASENOTES |
- includes
<stdalign.h>
, if detected as available, or provides replacement code. This enablesalignof
andalignas
. - provides
__builtin_expect
, if not available. - provides dummy implementations for
__has_feature
and__has_attribute
, which always return 0 (NO). - provides the
MULLE_C_STRINGIFY
macro, which creates a string from the given identifier (MULLE_C_STRINGIFY( a)
creates"a"
). - provides the
MULLE_C_CONCAT
macro to concatenate two identifiers (MULLE_C_CONCAT( a, b)
createsab
). - provides
MULLE_C_ASSERT
for compile time assertions, e.g.MULLE_C_ASSERT( sizeof( foo) <= sizeof( void *)
- provides support for constructor and destructor functions see below
- provides a collection of undocumented, fancy preprocessor evaluation macros in mulle-c11/mulle-c11-eval.h
- SYNTAX.md explains the naming scheme in data structures used throughout the mulle-c projects
Compilation hints like __attribute__(( <name>))
are usually only available
for gcc and clang. These mulle-c11 macros allow compilation with other
compilers.
Attribute | mulle-c11 | Description |
---|---|---|
always_inline |
MULLE_C_ALWAYS_INLINE |
Force inlining of function |
const |
MULLE_C_CONST |
Mark function return value as constant given same input parameters |
deprecated |
MULLE_C_DEPRECATED |
Mark function as deprecated |
never_inline |
MULLE_C_NEVER_INLINE |
Prevent inlining of function |
nonnull |
MULLE_C_NONNULL_FIRST |
Marks first function parameter as not accepting NULL. There is also MULLE_C_NONNULL_SECOND and combinations like MULLE_C_NONNULL_FIRST_FOURTH up to five parameters |
noreturn |
MULLE_C_NO_RETURN |
Mark function as not returning (e.g. abort ) |
returns_nonnull |
MULLE_C_NONNULL_RETURN |
Mark function as never returning zero (NULL) |
Constructor functions are executed when the containing object
file is loaded. In a static executable, this is guaranteed before main
.
In shared library environments, it depends on when the shared library is
loaded. Destructor functions are called before the unloading of the shared
library or before the exit of the executable.
MULLE_C_CONSTRUCTOR( load)
static void load( void)
{
printf( "load\n");
}
MULLE_C_DESTRUCTOR( unload)
static void unload( void)
{
printf( "unload\n");
}
MULLE_C11_CONSTRUCTOR( f) void f( void);
will expand differently, depending
on the compiler and operating system:
__attribute__((constructor)) void f( void);
static void f(void);
__declspec(allocate(".CRT$XCU")) void (*f_)(void) = f;
__pragma(comment(linker,"/include:" p "f_"))
This project is a component of the mulle-core library. As such you usually will not add or install it
individually, unless you specifically do not want to link against
mulle-core
.
Use mulle-sde to add mulle-c11 to your project:
mulle-sde add github:mulle-c/mulle-c11
To only add the sources of mulle-c11 with dependency sources use clib:
clib install --out src/mulle-c mulle-c/mulle-c11
Add -isystem src/mulle-c
to your CFLAGS
and compile all the sources that were downloaded with your project.
Use mulle-sde to build and install mulle-c11:
mulle-sde install --prefix /usr/local \
https://github.com/mulle-c/mulle-c11/archive/latest.tar.gz
Download the latest tar or zip archive and unpack it.
Install mulle-c11 into /usr/local
with cmake:
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_PREFIX_PATH=/usr/local \
-DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config Release
The Preprocessor evaluation feature is indebted mostly to
C Preprocessor tricks, tips, and idioms and
Preprocessor: __VA_ARGS__
: count arguments
Nat! for Mulle kybernetiK