bfx
An interpreter, compiler, and REPL for brainfuck-like languages
Loading...
Searching...
No Matches
compile.h File Reference
#include "bfx.h"

Go to the source code of this file.

Macros

#define BFX_DEFAULT_COMPILER   "gcc"
 Default compiler to use when compiling generated C code.
 
#define BFX_DEFAULT_COMPILE_FLAGS   "-O3 -s -ffast-math -static"
 Default compile flags to use when compiling generated C code.
 
#define BFX_COMPILER_LDFLAGS   "-lbfx -lm"
 Default linker flags to use when compiling generated C code.
 
#define BFX_COMPILE_HEAD   "#include <bfx/interpret.h>\nint main(void) {BFX bfx;"
 Head of the compiled program.
 
#define BFX_TMP_FILE_PATH   "/tmp/bfx.c"
 Path to the temporary file used for compilation.
 

Functions

void bfx_compile (const char *, const char *, BFX *)
 Compile Brainfuck code from input_path to output_path.
 

Detailed Description

This file contains the public definitions for the Brainfuck-like language compiler.

Macro Definition Documentation

◆ BFX_COMPILE_HEAD

#define BFX_COMPILE_HEAD   "#include <bfx/interpret.h>\nint main(void) {BFX bfx;"

Head of the compiled program.

◆ BFX_COMPILER_LDFLAGS

#define BFX_COMPILER_LDFLAGS   "-lbfx -lm"

Default linker flags to use when compiling generated C code.

◆ BFX_DEFAULT_COMPILE_FLAGS

#define BFX_DEFAULT_COMPILE_FLAGS   "-O3 -s -ffast-math -static"

Default compile flags to use when compiling generated C code.

◆ BFX_DEFAULT_COMPILER

#define BFX_DEFAULT_COMPILER   "gcc"

Default compiler to use when compiling generated C code.

◆ BFX_TMP_FILE_PATH

#define BFX_TMP_FILE_PATH   "/tmp/bfx.c"

Path to the temporary file used for compilation.

Function Documentation

◆ bfx_compile()

void bfx_compile ( const char *  input_path,
const char *  output_path,
BFX bfx 
)

Compile Brainfuck code from input_path to output_path.

This function takes a Brainfuck source code file specified by input_path, compiles it into a C program, compiles the C program, and writes the resulting code to the file specified by output_path. If input_path is NULL, the function will read from stdin. If output_path is NULL, the function will write to ./a.out.

Parameters
input_pathPath to the input Brainfuck source code file.
output_pathPath to the output binary or C file.
bfxBFX configuration to use for compilation.