x-engine-c v0.2.13
The C engine for x-lang
Loading...
Searching...
No Matches
x.h File Reference

Core definitions for computational expressions. More...

#include <stdarg.h>

Go to the source code of this file.

Macros

Constants
#define X_VERSION   "0.1.0"
 
#define X_MACHINE   "undefined"
 
#define X_ARCH   "undefined"
 
Debug Utilities
#define x_debug_va(fd, fmt, ap)   {}
 
#define x_debug(fd, fmt, ...)   {}
 

Functions

void x_error (int fd, x_char_t *message, x_char_t *p_text)
 

Basic Types

#define X_INT_STR_PRINTF_CONV   "l"
 
#define X_INT_CHAR_PRINTF_CONV   "c"
 
#define X_STR_LITERAL(s)   (x_char_t *)(s), (sizeof(s) - 1)
 
typedef long x_int_t
 
typedef char x_assert_int_ptr_size[sizeof(x_int_t)==sizeof(void *) ? 1 :-1]
 
typedef char x_char_t
 

Detailed Description

Core definitions for computational expressions.

Provides fundamental types, architecture detection, debug utilities, and error handling for the x-expr library.

Compile-time toggles (disabled by default, define on the compiler command line or uncomment below):

  • X_USE_STDLIB – Delegate x-lib functions to their stdlib equivalents (memcpy, strlen, strcmp, etc.).
  • X_USE_STDLIB_NONSTD – Use non-standard library extensions (e.g. ltoa). Requires X_USE_STDLIB.
  • X_HEAP – Enable heap management and garbage collection. Required by x-heap.h.
Author
Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

Macro Definition Documentation

◆ X_ARCH

#define X_ARCH   "undefined"

The C compiler's target CPU architecture as a string literal.

Determined by probing compiler predefined macros for known architecture values. Resolves to one of: "alpha", "amd64", "arm", "arm64", "blackfin", "convex", "epiphany", "pa_risc", "x86", "ia64", "m68k", "mips", "powerpc", "pyramid9810", "rs6000", "sparc", "superh", "systemz", "tms320", "tms470", or "undefined".

Adapted from https://sourceforge.net/p/predef/wiki/Architectures/

◆ x_debug

#define x_debug (   fd,
  fmt,
  ... 
)    {}

◆ x_debug_va

#define x_debug_va (   fd,
  fmt,
  ap 
)    {}

◆ X_INT_CHAR_PRINTF_CONV

#define X_INT_CHAR_PRINTF_CONV   "c"

Printf conversion specifier for x_char_t values.

◆ X_INT_STR_PRINTF_CONV

#define X_INT_STR_PRINTF_CONV   "l"

Printf length modifier for x_int_t values (e.g. "l" for long).

◆ X_MACHINE

#define X_MACHINE   "undefined"

The C compiler's target machine identifier.

For example, i686-pc-linux-gnu. To override the default value of "undefined", pass a value to the C preprocessor via the command line. When supported by the compiler, this is typically the output of the -dumpmachine switch.

◆ X_STR_LITERAL

#define X_STR_LITERAL (   s)    (x_char_t *)(s), (sizeof(s) - 1)

Expand a string literal into a pointer and length pair.

Produces two arguments: a (x_char_t *) pointer and the string length (excluding the null terminator). Useful with x_sys_write().

Parameters
sA string literal.

◆ X_VERSION

#define X_VERSION   "0.1.0"

The current version of the x-expr library.

Version numbering conforms to the Semantic Versioning specification.

Typedef Documentation

◆ x_assert_int_ptr_size

typedef char x_assert_int_ptr_size[sizeof(x_int_t)==sizeof(void *) ? 1 :-1]

Compile-time assertion that x_int_t and pointers are the same size.

◆ x_char_t

typedef char x_char_t

The character type used throughout x-expr.

◆ x_int_t

typedef long x_int_t

The integer type used throughout x-expr. Sized to match pointer width.

Function Documentation

◆ x_error()

void x_error ( int  fd,
x_char_t message,
x_char_t p_text 
)

Output an error message to a file descriptor.

Output an error message to a file descriptor.

Writes "*** ERROR: " followed by message. If p_text is non-NULL, appends ‘" &rsquo;"` and the context text.

Parameters
fdFile descriptor to write the error to.
messageA C string error message to output.
p_textA C string with additional context, or NULL.