burtonsamograd / sxc

sxc is an 'S-Expression C' transpiler for generating C code using macros written in Common Lisp
212 stars 10 forks source link

Representing struct declarations #1

Closed jpraher closed 7 years ago

jpraher commented 7 years ago

thanks for the interesting project. One question regarding the use of struct definitions.

How would one introduce a new type via a struct declaration? I was not able to compile for instance

(struct pair (int first) (int second))

into

struct pair { int first; int second; };

I have quickly looked over the source code. In the code for c-output-variable-decleration structs are mentioned, yet this is only then part of a concrete variable declaration. The point would be to declare the struct once and then use the struct via struct name in the variable declaration.

What is your opinion on that?

burtonsamograd commented 7 years ago

Yes, structs definitely need to be added. I'll see what I can do or will accept a PR.

burtonsamograd commented 7 years ago

Done. See commit https://github.com/burtonsamograd/sxc/commit/78fca115184ffb05a8750fe0cf01877804a9a2af.

burtonsamograd commented 1 year ago

But it's not correct. I tried it further and found bugs. I thought I added it when I initially wrote it but this reminds me that I didn't and maybe just hacked it. Further testing showed it didn't work, at least in the obvious case of use. It was a new style of programming for me to use struct based databases in sxc, but once i found the bug i moved on. It does open up more options for programming in C. I might get to fixing it.

-- Burton 2023