News for hackers. Stuff that matters.

Tools to generate constants and enums in multiple languages

I would like to generate constants (and ideally enums) from a single source into multiple languages so that I don't need to maintain multiple definitions.

I'd like to support at least: C, C++, C#, Rust, Javascript

So far the closest thing I've found is reconstant[0], which looks simple enough to add C# to but curious what other options are available.

( 3 comments | 4 points | on HN )
Re:Tools to generate constants and enums in multiple languages by avinassh on Thursday November 11, 2021 @09:36AM (#29188226)
Re:Tools to generate constants and enums in multiple languages by tossaway9000 on Thursday November 11, 2021 @10:02AM (#29188538)
I glossed over it early on as it didn't support mention Rust support, it also seemed to be for a different use case than I was targeting but I'll give it another look. Thanks for the suggestion.
Re:Tools to generate constants and enums in multiple languages by tossaway9000 on Thursday November 11, 2021 @10:14AM (#29188692)
Update: protocol buffers look more promising than I initially gave it credit and there is a Rust implementation.