Skip to content

Commit bd130ef

Browse files
committed
Work around swprintf being wrong in FB's stdio.bi, which would have broke heaps of functions (and caused compile warnings)
1 parent 4dffcbd commit bd130ef

6 files changed

+18
-8
lines changed

crt_extra/stdio.bi

+13
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,17 @@ extern "C"
2828

2929
#endif
3030

31+
'msvcrt has swprintf/vswprintf functions which differ from POSIX, and FB's
32+
'stdio.bi header is based on mingw/msvcrt. IMO FB ought to try to hide these
33+
'sorts of platform deficiencies to make it easier to write cross-platform code.
34+
#undef swprintf
35+
#undef vswprintf
36+
#ifdef __FB_WIN32__
37+
declare function swprintf alias "snwprintf" (byval s as wchar_t ptr, byval n as size_t, byval format as wchar_t ptr, ...) as long
38+
declare function vswprintf alias "vsnwprintf" (byval s as wchar_t ptr, byval n as size_t, byval format as wchar_t ptr, byval arg as va_list) as long
39+
#else
40+
declare function swprintf (byval s as wchar_t ptr, byval n as size_t, byval format as wchar_t ptr, ...) as long
41+
declare function vswprintf (byval s as wchar_t ptr, byval n as size_t, byval format as wchar_t ptr, byval arg as va_list) as long
42+
#endif
43+
3144
end extern

dev_file_eoc.bas

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/' detects EOF for file device '/
22

33
#include "fb.bi"
4-
#include "crt_extra/stdio.bi"
54

65
extern "C"
76
function fb_DevFileEof( handle as FB_FILE ptr ) as long
@@ -45,4 +44,4 @@ function fb_DevFileEof( handle as FB_FILE ptr ) as long
4544
FB_UNLOCK()
4645
return iif(eof__ <> 0, FB_TRUE, FB_FALSE)
4746
end function
48-
end extern
47+
end extern

dev_file_seek.bas

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/' file device '/
22

33
#include "fb.bi"
4-
#include "crt_extra/stdio.bi"
54

65
extern "C"
76
function fb_DevFileSeek( handle as FB_FILE ptr, offset as fb_off_t, whence as long ) as long
@@ -23,4 +22,4 @@ function fb_DevFileSeek( handle as FB_FILE ptr, offset as fb_off_t, whence as lo
2322

2423
return res
2524
end function
26-
end extern
25+
end extern

dev_file_size.bas

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/' file device size calc '/
22

33
#include "fb.bi"
4-
#include "crt_extra/stdio.bi"
54

65
extern "C"
76
function fb_hDevFileSeekStart( fp as FILE ptr, mode as long, encod as FB_FILE_ENCOD, seek_zero as long ) as long
@@ -51,4 +50,4 @@ function fb_DevFileGetSize( fp as FILE ptr, mode as long, encod as FB_FILE_ENCOD
5150

5251
return size
5352
end function
54-
end extern
53+
end extern

dev_file_tell.bas

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/' file device '/
22

33
#include "fb.bi"
4-
#include "crt_extra/stdio.bi"
54

65
extern "C"
76
function fb_DevFileTell( handle as FB_FILE ptr, pOffset as fb_off_t ptr ) as long
@@ -22,4 +21,4 @@ function fb_DevFileTell( handle as FB_FILE ptr, pOffset as fb_off_t ptr ) as lon
2221

2322
return fb_ErrorSetNum( FB_RTERROR_OK )
2423
end function
25-
end extern
24+
end extern

fb.bi

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/' FB's CRT headers need some work. Any additions to them that aren't
1212
yet merged into FB are in these extra headers '/
1313
#include "crt_extra/string.bi"
14+
#include "crt_extra/stdio.bi"
1415

1516
#define FB_TRUE (-1)
1617
#define FB_FALSE 0

0 commit comments

Comments
 (0)