{"id":988,"date":"2020-12-02T16:22:00","date_gmt":"2020-12-02T23:22:00","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=988"},"modified":"2020-12-16T12:29:32","modified_gmt":"2020-12-16T19:29:32","slug":"xojo-arrays-always-32-bit-array","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2020\/12\/02\/xojo-arrays-always-32-bit-array\/","title":{"rendered":"Where Xojo isnt fully 64 bit"},"content":{"rendered":"\n<p>In Xojo an array is limited to being <a href=\"http:\/\/feedback.xojo.com\/case\/62876\">no more than 2 billion entries<\/a> (<code>2,147,483,646<\/code>\u00a0)<\/p>\n\n\n\n<p>But arrays are documented as using integers which, in a 64 bit world, should be a LOT more entries than this.<\/p>\n\n\n\n<p>When this post was written the documentation isnt clear about what the maximum size of an array IS. It just said :<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>size<\/td><td><a href=\"http:\/\/docs.xojo.com\/Integer\">Integer<\/a><\/td><td>The upper bound of the array. Size must be a number or a&nbsp;<a href=\"http:\/\/docs.xojo.com\/Const\">constant<\/a>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Thats been altered now and the case noted above marked &#8220;fix&#8221; . Documenting a shortcoming isnt the same as fixing the shortcoming though. <\/p>\n\n\n\n<p>In a 64 bit application Integer usually means a 64 bit integer but in reality arrays dont use Integer, they use Int32. This<a href=\"http:\/\/feedback.xojo.com\/case\/62518\"> limitation isnt considered a bug <\/a>as <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>The Integer type is Xojo compiler\/framework magic. Behind the scenes, LastIndex (and Ubound) are Int32 because we still support 32 bit OSs. Should the day come when we no longer support 32 bit operating systems, we could then change arrays to Int64 but even that would then be a LOT of work involving updating the compiler, the frameworks, etc.<\/p><\/blockquote>\n\n\n\n<p>In most Xojo code and use cases we never have to worry about &#8220;compiler magic&#8221;<sup>1<\/sup> etc and integer is an Int64 in 64 bit apps and an Int32 in 32 bit programs.<\/p>\n\n\n\n<p>As users we shouldn&#8217;t have to know, or care about &#8220;magic&#8221; &#8211; it should just work like it does everywhere else.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>1 In a language like C++ this &#8220;magic&#8221; amounts to something like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ your C++ compiler MAY define specific tags to tell if you're compiling 32 or 64 bit\n#if 64Bit \/\/ with whatever specific code your C++ compiler needs to tell this is a 64 bit build\n   typedef int64_t integer ;\n#elif 32Bit \/\/ with whatever specific code your C++ compiler needs to tell this is a 64 bit build\n   typedef int32_t integer ;\n#endif<\/code><\/pre>\n\n\n\n<p>They even have code in their headers for plugins that handles this (this is from the 2020r2 Plugin SDK include file REALplugin.h)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#if defined(__LP64__) || defined(_WIN64)\n\t#define TARGET_64BIT 1\n#else\n\t#define TARGET_64BIT 0\n#endif\n\n#include &lt;stdint.h&gt;\n#include &lt;stddef.h&gt;\n\ntypedef int64_t RBInt64;\ntypedef uint64_t RBUInt64;\ntypedef int8_t RBBoolean;\ntypedef uint32_t RBColor;\n\n#if TARGET_64BIT\n\ttypedef int64_t RBInteger;\n\ttypedef uint64_t RBUInteger;\n#else\n\ttypedef int32_t RBInteger;\n\ttypedef uint32_t RBUInteger;\n#endif<\/code><\/pre>\n\n\n\n<p>UPDATE : Christian <a href=\"https:\/\/forum.xojo.com\/t\/ptr-double-broken-for-2-gb\/59504\">found another spot<\/a> where Xojo isnt 64 bit <\/p>\n\n\n\n<p>UPDATE : Xojo <a href=\"http:\/\/feedback.xojo.com\/case\/62876\">fixed the documentation<\/a> and marked the original report &#8220;fixed&#8221;. But fixing the docs doesnt fix the actual issue reported.<br>I have an older feature request to <a href=\"http:\/\/feedback.xojo.com\/case\/56085\">make arrays 64 bit<\/a><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Xojo an array is limited to being no more than 2 billion entries (2,147,483,646\u00a0) But arrays are documented as using integers which, in a 64 bit world, should be a LOT more entries than this. When this post was written the documentation isnt clear about what the maximum size of an array IS. It &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2020\/12\/02\/xojo-arrays-always-32-bit-array\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Where Xojo isnt fully 64 bit&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-988","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=988"}],"version-history":[{"count":7,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/988\/revisions"}],"predecessor-version":[{"id":1014,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/988\/revisions\/1014"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}