Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct initialization #121

Open
shelvick opened this issue Apr 23, 2022 · 0 comments
Open

Struct initialization #121

shelvick opened this issue Apr 23, 2022 · 0 comments

Comments

@shelvick
Copy link

Use case: I have two nested structs, and I want to ensure that one of their respective fields contains/points to the same object (i.e. EQ, not just EQL). Example C code:

typedef struct Foo {
  int x;
} Foo;

typedef struct Bar {
  Foo foo;
} Bar;

I want to create two Bar objects with EQ foo's. So in Lisp:

(c-let ((bar1 bar)
        (bar2 bar))
  (setf (bar.foo bar2) (bar.foo bar1)))

But of course this fails, because cl-autowrap doesn't support setting structs directly. It seems simple, but I cannot for the life of me figure out how to make this work. If there were a way to initialize bar2 with a pre-existing foo, then I could work around the limitation to a large extent. I don't see a way though.

Are there any other workarounds for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant