Skip to content

Native modules do not support const, enum and type properly. #1735

Closed
@beoran

Description

@beoran

When playing around with rust 0.1 and trying to wrap Allegro, a game programming library with it I noticed that it's not possible to use enum , or const in a native module . This is annoying since it means I have to use a second non-native module to define the C constants and enums that Allegro uses. Also, type doesn't work well, so again, I have to use another non-native module to define the struct types for Allegro. Could all this be allowed in the future?

Below is an example rewritten for libc:

use std;
import std::io;

mod libc1_nn  {
  enum test { zero, one, two, three }
}


#[nolink]
native mod libc1  {
  enum test { zero, one, two, three } 
}


mod libc2_nn  {
  const constant : int = 10;
}


#[nolink]
native mod libc2  {
  const constant : int = 10;
}


mod libc3_nn {
  type rec = { a : c_int , b : c_int };
}


#[nolink]
native mod libc3  {
  import ctypes::*;
  type rec = { a : c_int , b : c_int };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions