Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing constants across languages

I have a long list of constants that I need access to in several projects which are in different languages(Verilog, C, C++ and C#). Rather than repeating them in each language, is there a good way to share these?

The only thing I could think of would be a text file and a preprocessing script? Is this the best solution or is there something easier/more elegant?

like image 404
Kristin Morris Avatar asked Aug 23 '10 18:08

Kristin Morris


3 Answers

A preprocessing script which automatically updates those constants within your code is probably the best method. Commit the code with your project to ensure correctness and have it a part of the build script.

like image 196
wheaties Avatar answered Oct 14 '22 21:10

wheaties


You can keep them in a XML document and write XSLT scripts for each language to generate the appropriate source files in each build.

like image 20
Henk Holterman Avatar answered Oct 14 '22 22:10

Henk Holterman


Can you use your makefile (or equivalent) to define these constants? For C and C++. you can use the compiler's CLI options to define pre-processor values for the constants. I haven't done much build customization for Verilog, but I suspect something similar might exist there as well.

like image 1
bta Avatar answered Oct 14 '22 22:10

bta