Interop with C/C++

A project log for Argentum programming language

It automatically prevents all memory leaks. It doesn't use GC, so no pauses. It's compiled to machine code. It's crazy safe and fast.

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