Skip to content

Add C Support. #23

Closed
Closed

Description

@treeform

C Support is nearly there as python has to talk though a C like interface.

Activity

  1. EchoPouet commented on Dec 2, 2021

    @EchoPouet

    Do you mean C++ right ? Because the readme indicates C support.

  2. treeform commented on Dec 2, 2021

    @treeform
    OwnerAuthor

    We are about 99% on the C support. We still have like 1% more to do.

  3. EchoPouet commented on Dec 3, 2021

    @EchoPouet

    For the C++ support it will be a simple formality ?

  4. treeform commented on Dec 3, 2021

    @treeform
    OwnerAuthor

    Well C++ can use C APIs yes, but I would not call them C++ APIs. For C++ APIs I expect name spaces, classes, operator overloading, polymorphism, exception throwing and maybe RAII. C++ should be treated as a different language. More like Nim or Java.

  5. EchoPouet commented on Dec 4, 2021

    @EchoPouet

    I totally agree with you. I hope your project will motivate developers to use Nim to create powerful libraries for other languages. And finally enlarge the community.

  6. jdf-id-au commented on Aug 9, 2022

    @jdf-id-au

    Thank you again for your incredible contributions.

    This is probably a naïve question. A proc returning a string gives a char* return type in the generated C header (after .cstring is called in internal.nim). What is the lifetime of this memory? Isn't the parent string vulnerable to garbage collection at Nim's will, and doesn't this affect the cstring's storage? Isn't it necessary to export memory management procs to accompany it (somewhat like system/allocCStringArray)?

    (I also noticed when experimenting that GC_ref and GC_unref don't seem to work for string under --gc:orc, but seem to under --gc:refc which genny doesn't support.)

  7. treeform commented on Aug 18, 2022

    @treeform
    OwnerAuthor

    We are aware of the problem with returning strings. We will probably implement some sort of buffer type or make ref/unref work with strings.

    For now it happens to work because pixie is single threaded, returning the string still keeps the data around for C to deal with. But yes as soon as you make another call the data can get clobbered.

    We will fix this.

  8. treeform commented on May 25, 2026

    @treeform
    OwnerAuthor

    I have fixed the last remaining issue with the returning string support and who owns the memory. I think C backend is now well tested. #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions