Skip to content

Support bindings for defines #4

@jonas

Description

@jonas

Certain symbols in the standard C library is exposed under the expected names using a #define rather than an extern global variable, e.g. stdin from stdio.h:

extern FILE *__stdinp;
// ...
#define stdin   __stdinp

The way this is handled in Scala Native is to generate a C function which simply returns the expected symbol, e.g.:

void *scalanative_libc_stdin() { return stdin; }

which is then bound using

@extern
object stdio {
  // ...
  @name("scalanative_libc_stdin")
  def stdin: Ptr[FILE] = extern
}

The questions is should the binding generator handle this case by generating C code or should it generate per platform bindings that use the final symbol, e.g.:

@extern
object stdio {
  // ...
  @name("__stdinp")
  def stdin: Ptr[FILE] = extern
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bindgenBinding generator

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions