Interop with C/C++

A project log for Argentum programming language

compiled, leak-free, no-GC, fast, small, modular, type-safe, memory-safe high-level simple programming language

Andrey KalmatskiyAndrey Kalmatskiy 05/08/2023 at 02:560 Comments

Argentum can natively call C/C++ functions, pass primitives, objects and raw structures (with sys_Blob object). Example:

In C/C++

#include <stdio.h>
#include "../argentum/src/runtime/runtime.h"

bool ag_fn_io_writeFile(AgString* name, AgString* content) {
  FILE* f = fopen(name->ptr, "wb");
  if (!f) return false;
  bool r = fputs(content->ptr, f) >= 0;
  return r;

In Argentum (file

using sys { String; log; }
fn writeFile(name String, content String) bool;

writeFile("1.txt", "File data") ? log("done")

More details are here: ffi-tutorial