zetzit / zz

πŸΊπŸ™ ZetZ a zymbolic verifier and tranzpiler to bare metal C
MIT License
1.6k stars 52 forks source link

Fix binary literal warning/error in non-GNU compilers #142

Closed jam1garner closed 3 years ago

jam1garner commented 3 years ago

Since binary literals aren't a part of the C standard, support for them ranges from nonexistent in some compilers, a warning in some (for example clang) and only truly supported in gcc (with the GNU extensions enabled). This is obviously not great for compatibility, so this commit normalizes all integer literals to decimal.

Examples of warning output by clang:

/home/jam/dev/zetz/zetzstd/src/main.zz:55:25: warning: binary integer literals are a GNU extension [-Wgnu-binary-literal]
  return (    desc &    0b11  );
                        ^
/home/jam/dev/zetz/zetzstd/src/main.zz:20:37: warning: binary integer literals are a GNU extension [-Wgnu-binary-literal]
  return ((    desc >>    6  ) &    0b11  );

Looking into this also brought to my attention that 0B is a valid prefix for binary literals under the GNU extension which binary literal support is presumably derived from (alternatively, Go also supports it). It is notable, however, that Rust does not support this prefix.

aep commented 3 years ago

Great! This is needed.

What do you think about emitting them as hex instead of dec?

jam1garner commented 3 years ago

Hex works for me, I've updated that to be the behavior of it.

jam1garner commented 3 years ago

(off topic) Just out of curiosity @aep, is there a zulip/discord/etc for zz discussion? Given the rather sparse documentation, I'd love to discuss the language/ideas/whatnot in a more synchronous manner than "read the source to learn enough to write some code so I can find bugs and contribute PRs in a way hopefully consistent with authorial intent" :P

aep commented 3 years ago

There's an irc channel at freenode #zetz . Happy to be convinced of something else, I'm not really up to date on which of the million corporate irc clones people actually use.

Also questions via github are totally fine :)

jam1garner commented 3 years ago

Just my two cents @aep but zulip has been surprisingly nice for Rust. It, to me at least, has a solid organizational structure for language development/discussion.

It feels like the good part of both mailing lists and irc while also having back history.

TLDR: irc-like channels, but each conversation is a "topic" a-la an email chain. Real time and more casual like irc, with the granularity of having as many easy-to-follow topics as you want within a given channel. (so like a topic might be "how #[repr(packed)] works")

(frankly I find it less stressful than both "questions as github issues" and IRC, but could not tell you why, however I certainly feel it's more accessible to new/younger users than IRC (and definitely mailing lists) which imo is a big plus)

Disclaimer: I am biased as I'd like to avoid setting back up my bouncer as I've found myself fortunate enough to be rid of irc for the past few years. But either way, excited to discuss zz, it seems to have a lot of neat stuff packed into it :)

Bonus: Zulip starts with a Z, so you can keep everything thematic :P

aep commented 3 years ago

allright, you're the second to suggest zulip, so i guess i'll adapt.

https://zetz.zulipchat.com

let me know if i should change some settings. i can see its for younger audiences, as the default font is too small for my aged eyes :D

aep commented 3 years ago

well or discord. see issue https://github.com/zetzit/zz/issues/143