Attemp to change Int for 64bit (long)


Active member
3rd Party Module Dev
3rd Party Tool Dev
Mar 5, 2018
Just wondering, is it too dificult to change the source for Cx (for my personal use).
I want to change Int size to use 64bit (long). Any suggession where to look at?
Do you think it is possible? Or is it a bad idea?
Is it difficult, it is possible and yes it would be a bad idea.

I'll start with the bad idea bit. If it requires any direct change to the trans module, then you would have to redo your changes to any new version of Cerberus; and you would only be able to do it with those targets that support C++.

To do it requires that you are familiar with how parser, translators and garbage collector work to add additional custom types, along with support functions that can do assignment and casting.

The general idea is to create an extern of the type to inject into the cpp code. You do this the same way as you would bind externa classes.
Class Long="long"

Then extend the CppTranslator to add functions to do casting, etc.
You then have to make sure that the new type is handled by the garbage collector.

For a very old example for Monkey X that shows the main concepts of the above. See wxMonkey.
wxMonkey will never work as it requires passing Void as method and function parameter, which the parser will no long allow.

There is possibly another way where you could try wrapping long in a generic class, but you may still get issues with trying to use it.
Last edited:
@dawlane. The question was about changing int from 32bit to 64Bit. Not add a new type. Or I didn’t understand your answer.
The question was about changing int from 32bit to 64Bit.
Data types would be defined by the tool chain being used and would require a major rewrite of the native code and the translators.
I would think that the simplest solution to that would be to create a new target and add a new translator for that target with changes for supporting 64bit int's aka int64_t or __int64; note long data types may still only be four bytes. But there would still have to be duplication of the core native sources such as the garbage collector.
Last edited:
You could roll your own long int class easily enough, though of course you would lose some efficiency and it would be an object rather than a primitive. (Or you could make functions that operate on int arrays.)
Thanks @Gerry Quinn for suggession. I alcually already done

But I just wondering if there are an easy way to use native long. I know CX take source code into other language. I see that CX to JS is already 64bit( I think) and I imagine that the issue is only about how declaration is done(translate) to other language. Base on target let say, java target; maybe on the case where CX parse global var:int=20 ... CX than translete instead of int var=20; into long var=20;

Well I believe it is not easy. Especially if other module was build along with 32bit in mind. I need to know how parser work in CX
Top Bottom