Skip to content

FFI documentation is too vague about importing/linking external C/C++ functions #6

@Natuworkguy

Description

@Natuworkguy

The current FFI documentation in src/docs/extern.md explains what extern does, but it does not explain how users are actually supposed to import and link external C/C++ functions into a Rux project.

Current docs:

# Foreign Function Interface

The `extern` keyword declares functions or variables that are defined outside Rux — typically in C / C++ libraries.

extern func malloc(size: uint) -> *opaque;
extern func free(ptr: *opaque);
extern func sin(angle: float) -> float;

Calling `extern` functions is inherently **unsafe**, as Rux cannot verify their behavior.

The issue is that this only shows declarations, not the full workflow required to use external libraries.

Some missing information that would be helpful:

  • How to link external libraries
  • Whether headers are needed
  • Whether Rux supports dynamic libraries, static libraries, or both
  • How C++ name mangling should be handled
  • Platform-specific examples (Windows/Linux/macOS)
  • Example build commands
  • A complete example showing:
    • C/C++ source
    • compilation
    • linking
    • calling from Rux

For new users, the docs currently make FFI look much simpler than it actually is, which can be confusing when trying to use real libraries.

A more complete example-based section would make the feature significantly easier to understand and adopt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions