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 error when compiling for Windows from Linux #23141

Closed
Calinou opened this issue Oct 19, 2018 · 6 comments
Closed

Build error when compiling for Windows from Linux #23141

Calinou opened this issue Oct 19, 2018 · 6 comments

Comments

@Calinou
Copy link
Member

Calinou commented Oct 19, 2018

Godot version: Git bde3e88

OS/device including version: Fedora 28, GCC 8.1.1

Issue description:

Compiling for Windows from Linux using MinGW fails with the following error:

Compiling ==> modules/websocket/lws_client.cpp
modules/websocket/lws_client.cpp: In member function 'virtual Error LWSClient::connect_to_host(String, String, uint16_t, bool, PoolVector<String>)':
modules/websocket/lws_client.cpp:87:41: error: invalid conversion from 'const char*' to 'size_t {aka long long unsigned int}' [-fpermissive]
  strncpy(abuf, addr_str.ascii().get_data(), 1023);
                ~~~~~~~~~~~~~~~~~~~~~~~~~^~
modules/websocket/lws_client.cpp:87:49: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
  strncpy(abuf, addr_str.ascii().get_data(), 1023);
                                                 ^
modules/websocket/lws_client.cpp:87:49: error: too few arguments to function 'errno_t strncpy_s(char*, size_t, const char*, size_t)'
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/string.h:190:0,
                 from ./core/os/copymem.h:42,
                 from ./core/dvector.h:34,
                 from ./core/variant.h:41,
                 from ./core/method_ptrcall.h:36,
                 from ./core/method_bind.h:35,
                 from ./core/class_db.h:34,
                 from ./core/reference.h:34,
                 from ./core/io/stream_peer.h:34,
                 from modules/websocket/lws_helper.h:36,
                 from modules/websocket/lws_client.h:36,
                 from modules/websocket/lws_client.cpp:32:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/sec_api/string_s.h:39:27: note: declared here
   _CRTIMP errno_t __cdecl strncpy_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
                           ^~~~~~~~~
modules/websocket/lws_client.cpp:89:38: error: invalid conversion from 'const char*' to 'size_t {aka long long unsigned int}' [-fpermissive]
  strncpy(hbuf, p_host.utf8().get_data(), 1023);
                ~~~~~~~~~~~~~~~~~~~~~~^~
modules/websocket/lws_client.cpp:89:46: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
  strncpy(hbuf, p_host.utf8().get_data(), 1023);
                                              ^
modules/websocket/lws_client.cpp:89:46: error: too few arguments to function 'errno_t strncpy_s(char*, size_t, const char*, size_t)'
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/string.h:190:0,
                 from ./core/os/copymem.h:42,
                 from ./core/dvector.h:34,
                 from ./core/variant.h:41,
                 from ./core/method_ptrcall.h:36,
                 from ./core/method_bind.h:35,
                 from ./core/class_db.h:34,
                 from ./core/reference.h:34,
                 from ./core/io/stream_peer.h:34,
                 from modules/websocket/lws_helper.h:36,
                 from modules/websocket/lws_client.h:36,
                 from modules/websocket/lws_client.cpp:32:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/sec_api/string_s.h:39:27: note: declared here
   _CRTIMP errno_t __cdecl strncpy_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
                           ^~~~~~~~~
modules/websocket/lws_client.cpp:91:38: error: invalid conversion from 'const char*' to 'size_t {aka long long unsigned int}' [-fpermissive]
  strncpy(pbuf, p_path.utf8().get_data(), 2047);
                ~~~~~~~~~~~~~~~~~~~~~~^~
modules/websocket/lws_client.cpp:91:46: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
  strncpy(pbuf, p_path.utf8().get_data(), 2047);
                                              ^
modules/websocket/lws_client.cpp:91:46: error: too few arguments to function 'errno_t strncpy_s(char*, size_t, const char*, size_t)'
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/string.h:190:0,
                 from ./core/os/copymem.h:42,
                 from ./core/dvector.h:34,
                 from ./core/variant.h:41,
                 from ./core/method_ptrcall.h:36,
                 from ./core/method_bind.h:35,
                 from ./core/class_db.h:34,
                 from ./core/reference.h:34,
                 from ./core/io/stream_peer.h:34,
                 from modules/websocket/lws_helper.h:36,
                 from modules/websocket/lws_client.h:36,
                 from modules/websocket/lws_client.cpp:32:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/sec_api/string_s.h:39:27: note: declared here
   _CRTIMP errno_t __cdecl strncpy_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
                           ^~~~~~~~~
scons: *** [modules/websocket/lws_client.windows.opt.tools.64.o] Error 1
scons: building terminated because of errors.

Full build log on GitLab CI

This is likely a regression from b902a2f.

@akien-mga
Copy link
Member

CC @dualtagh @Faless

@Faless
Copy link
Collaborator

Faless commented Oct 19, 2018

This is quite surprising... it compiles for me, though it clearly shouldn't, strncpy and strncpy_s have a different signature, and we are just replacing the tokens here (I guess my build do not have MINGW_ENABLED set?) maybe I should just use C++ strncpy_s directly in that file:

#if defined(MINGW_ENABLED) || defined(_MSC_VER)
#define strncpy strncpy_s
#endif

@Faless
Copy link
Collaborator

Faless commented Oct 19, 2018

maybe I should just use C++ strncpy_s directly in that file

I don't really like to bump the module to C++11 for that...

@fire
Copy link
Member

fire commented Oct 21, 2018

Any progress? Builds have been broken for 2 days.

@akien-mga
Copy link
Member

akien-mga commented Oct 21, 2018

A quick fix would likely be to remove defined(MINGW_ENABLED) || in the offending file.

@fire
Copy link
Member

fire commented Oct 23, 2018

Trying

#if !defined(MINGW_ENABLED) && defined(_MSC_VER)
#define strncpy strncpy_s
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants