heroseh / hcc

C Compiler to SPIR-V
MIT License
306 stars 11 forks source link

Noticed the preprocessor doesn't handle an obscure case #1

Closed scallyw4g closed 2 years ago

scallyw4g commented 2 years ago

Saw you programming on Twitch the other day. I'm also writing a C compiler and I decided to take a closer look at hcc.

I had to fix a typo to get it to compile. I'm assuming I did the right thing .. but .. it is in the preprocessor code. Anyhow..

During my reading I noticed the hcc preprocessor doesn't handle a weird case that's pretty rare (AFAIK) in the wild, but I did run into it parsing the handmade hero codebase.

Here's a link to some documentation about it: https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

Both clang and gcc accept the demo code I wrote, fwiw.

Looking forward to using hcc in the future!!

heroseh commented 2 years ago

Hey, thank you for taking interest in the project. I have made the correction you made in src/hcc.c into my next commit.

As for the other feature you mentioned, that is not valid C. It is a C extension, although i will support the odd extension here and there. They are not on the top of the priority. You can get around needing that feature in C anyway by just making your whole macro have 1 parameter thats a variable arg (...)

scallyw4g commented 2 years ago

Ah, got it. That's a pretty fair stance for a new project. Best of luck!