Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure on armv7 FreeBSD 13.1 #172

Closed
clausecker opened this issue Aug 12, 2022 · 1 comment
Closed

Build failure on armv7 FreeBSD 13.1 #172

clausecker opened this issue Aug 12, 2022 · 1 comment

Comments

@clausecker
Copy link

Building bonzomatic on armv7 FreeBSD 13.1, the build fails due to a missing cast.

/usr/bin/c++ -DGTK -DSCI_LEXER -DSCI_NAMESPACE -I/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/src -I/usr/local/include/stb -I/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/external/miniaudio -I/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/external/kiss_fft -I/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/external/kiss_fft/tools -I/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/external/jsonxx -I/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/external/scintilla/include -I/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/external/scintilla/lexlib -I/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/external/scintilla/src -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -std=c++11 -pthread -MD -MT CMakeFiles/bonzomatic.dir/src/main.cpp.o -MF CMakeFiles/bonzomatic.dir/src/main.cpp.o.d -o CMakeFiles/bonzomatic.dir/src/main.cpp.o -c /wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/src/main.cpp
/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/src/main.cpp:482:31: error: non-constant-expression cannot be narrowed from type 'int' to 'wchar_t' in initializer list [-Wc++11-narrowing]
          wchar_t utf16[2] = {Renderer::keyEventBuffer[i].character, 0};
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/graphics/bonzomatic/work/Bonzomatic-2022-06-18/src/main.cpp:482:31: note: insert an explicit cast to silence this issue
          wchar_t utf16[2] = {Renderer::keyEventBuffer[i].character, 0};
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              static_cast<wchar_t>(                )
1 error generated.

This is likely because char and wchar_t are unsigned types on ARM platforms, whereas they are signed on many other platforms. You may be able to reproduce this build failure on other platforms by compiling with -funsigned-char. In the FreeBSD project, we have added this patch to work around the issue:

--- src/main.cpp.orig	2022-07-08 20:07:06 UTC
+++ src/main.cpp
@@ -503,7 +503,7 @@ int main( int argc, const char * argv[] )
         if ( !consumed && Renderer::keyEventBuffer[ i ].character )
         {
           char    utf8[ 5 ] = { 0,0,0,0,0 };
-          wchar_t utf16[ 2 ] = { Renderer::keyEventBuffer[ i ].character, 0 };
+          wchar_t utf16[ 2 ] = { static_cast<wchar_t>(Renderer::keyEventBuffer[ i ].character), 0 };
           Scintilla::UTF8FromUTF16( utf16, 1, utf8, 4 * sizeof( char ) );
           mShaderEditor.AddCharUTF( utf8, (unsigned int) strlen( utf8 ) );
         }

Please check if the same patch can be applied to your code base or if some other fix is needed.

@clausecker
Copy link
Author

Duplicate of PR #171.

@clausecker clausecker closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant