Author Topic: Can`t build C::B IDE from latest svn revision 12240  (Read 13178 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Can`t build C::B IDE from latest svn revision 12240
« Reply #30 on: January 11, 2021, 11:21:07 pm »
Building CB myself using MSys2 MinGW64 64 bit and I think squirrel needs patched I am not sure that this patch is correct.

1. It is poorly formatted ( should I use tabs or spaces should I indent the tests or not. )
2. I am testing if __USE_MINGW_ANSI_STDIO is defined; but, maybe I need to test if the value is 1 or not zero.

Code
diff --git a/src/sdk/scripting/squirrel/sqdebug.cpp b/src/sdk/scripting/squirrel/sqdebug.cpp
index 7f96c4f..df3ef5f 100644
--- a/src/sdk/scripting/squirrel/sqdebug.cpp
+++ b/src/sdk/scripting/squirrel/sqdebug.cpp
@@ -76,7 +76,11 @@ SQString *SQVM::PrintObjVal(const SQObject &o)
  case OT_INTEGER:
  // C::B patch: Support for Windows 64 bit
  #if defined(_WIN64)
- scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%I64d"), _integer(o));
+            #if defined(__USE_MINGW_ANSI_STDIO)
+                scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%lld"), _integer(o));
+            #else
+                scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%I64d"), _integer(o));
+            #endif
  // C::B patch: Support for Linux 64 bit
  #elif defined(_SQ64)
  scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%ld"), _integer(o));
diff --git a/src/sdk/scripting/squirrel/sqfuncstate.cpp b/src/sdk/scripting/squirrel/sqfuncstate.cpp
index f98c757..28e55c7 100644
--- a/src/sdk/scripting/squirrel/sqfuncstate.cpp
+++ b/src/sdk/scripting/squirrel/sqfuncstate.cpp
@@ -82,7 +82,11 @@ void DumpLiteral(SQObjectPtr &o)
  case OT_INTEGER:
  // C::B patch: Support for Windows 64 bit
             #if defined(_WIN64)
-            scprintf(_SC("{%I64d}"),_integer(o));
+            #if defined(__USE_MINGW_ANSI_STDIO)
+                scprintf(_SC("{%lld}"),_integer(o));
+            #else
+                scprintf(_SC("{%I64d}"),_integer(o));
+            #endif
  // C::B patch: Support for Linux 64 bit
             #elif defined(_SQ64)
             scprintf(_SC("{%ld}"),_integer(o));
diff --git a/src/sdk/scripting/squirrel/sqvm.cpp b/src/sdk/scripting/squirrel/sqvm.cpp
index b1e91b5..d12f959 100644
--- a/src/sdk/scripting/squirrel/sqvm.cpp
+++ b/src/sdk/scripting/squirrel/sqvm.cpp
@@ -251,7 +251,11 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
  case OT_INTEGER:
  // C::B patch: Support for Windows 64 bit
         #if defined(_WIN64)
- scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%I64d"),_integer(o));
+            #if defined(__USE_MINGW_ANSI_STDIO)
+                scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%lld"),_integer(o));
+            #else
+                scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%I64d"),_integer(o));
+            #endif
  // C::B patch: Support for Linux 64 bit
  #elif  defined(_SQ64)
  scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%ld"),_integer(o));

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Can`t build C::B IDE from latest svn revision 12240
« Reply #31 on: January 12, 2021, 12:28:56 am »
Patching it for what? What is the error you're trying to fix?
I'm pretty sure we're not supposed to use __USE_MINGW_ANSI_STDIO.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Can`t build C::B IDE from latest svn revision 12240
« Reply #32 on: January 12, 2021, 02:43:51 am »
Patching it for what? What is the error you're trying to fix?
I'm pretty sure we're not supposed to use __USE_MINGW_ANSI_STDIO.

Building using the MSys2 MinGW64 64 bit GCC; it does not support "I64d" printf option.
Edit: And the compiler defines "__USE_MINGW_ANSI_STDIO" to 1 to show this fact.
Edit2: The define is in C:\msys64\mingw64\include\c++\10.2.0\x86_64-w64-mingw32\bits\os_defines.h
I have yet to find if it is defined for C only code.

Tim S.
« Last Edit: January 12, 2021, 03:16:00 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline omlk

  • Multiple posting newcomer
  • *
  • Posts: 110
« Last Edit: January 12, 2021, 09:53:06 am by omlk »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Can`t build C::B IDE from latest svn revision 12240
« Reply #34 on: January 12, 2021, 10:06:11 am »
@stahta01: I guess omlk wanted to point you to PRxNN macros, but he/she was so vague that I'm not sure he/she succeeded :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Can`t build C::B IDE from latest svn revision 12240
« Reply #35 on: January 13, 2021, 05:57:57 am »
@stahta01: I guess omlk wanted to point you to PRxNN macros, but he/she was so vague that I'm not sure he/she succeeded :)

Likely true; but, I have no idea if that would really be the clearest fix for third party code.

From MSys2 _mingw.h it seem to clearly imply my patch should either use __USE_MINGW_ANSI_STDIO equal 1 or use the PRxNN macros. Will have to further research. And, the problem seems to be MinGW64 instead of MSys2 based.
Code
/* We are activating __USE_MINGW_ANSI_STDIO for various define indicators.
 * printf ll modifier (unsupported by msvcrt.dll) is required by C99 and C++11 standards. */
#if (defined (_POSIX) || defined (_POSIX_SOURCE) || defined (_POSIX_C_SOURCE) \
     || defined (_ISOC99_SOURCE) \
     || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && __MSVCRT_VERSION__ < 0xE00) \
     || (defined (__cplusplus) && __cplusplus >= 201103L && __MSVCRT_VERSION__ < 0xE00) \
     || defined (_XOPEN_SOURCE) || defined (_XOPEN_SOURCE_EXTENDED) \
     || defined (_GNU_SOURCE) \
     || defined (_SVID_SOURCE)) \
    && !defined(__USE_MINGW_ANSI_STDIO)
/* Enable __USE_MINGW_ANSI_STDIO if user did _not_ specify it explicitly... */
#  define __USE_MINGW_ANSI_STDIO 1
#endif

/* We are defining __USE_MINGW_ANSI_STDIO as 0 or 1 */
#if !defined(__USE_MINGW_ANSI_STDIO)
#define __USE_MINGW_ANSI_STDIO 0      /* was not defined so it should be 0 */
#elif (__USE_MINGW_ANSI_STDIO + 0) != 0 || (1 - __USE_MINGW_ANSI_STDIO - 1) == 2
#define __USE_MINGW_ANSI_STDIO 1      /* was defined as nonzero or empty so it should be 1 */
#else
#define __USE_MINGW_ANSI_STDIO 0      /* was defined as (int)zero and non-empty so it should be 0 */
#endif

Edit: Decided to build using 32 bit MinGW64 to see if I get any warning like when using 64 bit.

Then try using non MSys2 GCC 64 bit and confirm the problem exists outside of MSys2 GCC.

Likely try the PRxNN macros based fix because it should be less complex to maintain; still not sure it is better long term.
But, when you have two choices the simpler one is the one to pick if you have no idea which is better.

Tim S.
« Last Edit: January 13, 2021, 06:06:36 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org