#55499 closed enhancement (fixed)
mingw-w64: missing secure api support
Reported by: | bruvzg | Owned by: | mojca (Mojca Miklavec) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | ||
Port: | mingw-w64 |
Description
mingw-w64
port is currently configured without --enable-secure-api
, so projects with "security-enhanced" (_s) functions fails to build. Major Linux distributions, MSYS2 and Cygwin build MinGW with --enable-secure-api
for both i686 and x86_64 targets.
I would like to suggest adding --enable-secure-api
configuration flag.
Change History (11)
comment:1 Changed 7 years ago by mf2k (Frank Schima)
Cc: | mojca@… removed |
---|---|
Owner: | set to mojca |
Port: | mingw-w64 added |
Status: | new → assigned |
comment:2 Changed 7 years ago by mojca (Mojca Miklavec)
Status: | assigned → accepted |
---|
comment:3 Changed 7 years ago by mojca (Mojca Miklavec)
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
comment:5 Changed 7 years ago by bruvzg
--enable-secure-api
should be added to -headers
subport, instead of -gcc
!
comment:6 Changed 7 years ago by mojca (Mojca Miklavec)
I'm sorry. Can you please send me an example to test the functionality?
comment:7 Changed 7 years ago by bruvzg
Example:
#include <cstdio> int main( void ) { FILE *stream = NULL; errno_t err = fopen_s( &stream, "data", "w+" ); if( err != 0 ) printf( "File 'data' was not opened\n" ); if( stream ) fclose( stream ); }
x86_64-w64-mingw32-gcc fopen_s.cpp -o fopen_s.exe
without --enable-secure-api
produce:
fopen_s.cpp: In function ‘int main()’: fopen_s.cpp:5:16: error: ‘fopen_s’ was not declared in this scope errno_t err = fopen_s( &stream, "data", "w+" ); ^~~~~~~ fopen_s.cpp:5:16: note: suggested alternative: ‘fopen64’ errno_t err = fopen_s( &stream, "data", "w+" ); ^~~~~~~ fopen64
Builds with --enable-secure-api
or with explicitly declared CXXFLAGS=-DMINGW_HAS_SECURE_API
.
Actual project I had problems with: https://github.com/syoyo/tinyexr
comment:8 Changed 7 years ago by mojca (Mojca Miklavec)
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:9 Changed 7 years ago by mojca (Mojca Miklavec)
Quote from chromium:
Windows XP does not provide secure API functions in
msvcrt.dll
but newer versions of Windows do. Avoid using secure API functions for compatibility withmsvcrt.dll
on Windows XP.
I guess XP is not too relevant, but it would be nice to update the build docs and at least mention a few words about what those flags do and why users might want to enable them by default.
comment:10 Changed 7 years ago by mojca (Mojca Miklavec)
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:11 Changed 7 years ago by mojca (Mojca Miklavec)
Please let me know in case this didn't solve the problem.
In the future, please fill in the Port field.