neslib / Chet

C Header Translator for Delphi
BSD 2-Clause "Simplified" License
204 stars 43 forks source link

Support for const declarations in header files: #12

Closed chiptamer closed 2 years ago

chiptamer commented 2 years ago

Added support for constants declared as [static] const AType AName = AnExpression; ("static" needed for C, can be omitted in C++)

E.g.

const int I = 5; // output -> I : Integer = 5; *static const char S = "Hi!"; // output -> S : PChar = 'Hi!'; const MY_INT_TYPE NUM = 42; // output-> NUM : MY_INT_TYPE = 42;**

Processing of the right hand side expression uses the code original used for #defined constants. This common code now resides in procedure WriteConstantsRhs(), and is called from procedure WriteDefinedConstant() (for #defines) and WriteTypedConstant() (for const statements as above)

P.S. My first pull request, hope I got everything right...

neslib commented 2 years ago

Thanks for contributing and your successful first pull request! Everything looked right to me, so I merged your code.

chiptamer commented 2 years ago

That was fast :-) Thank you for sharing this very helpful piece of software!