Problem with vsnprintf and MSVC6
Hi, Would this patch work on unix it works for me on MSVC6: Index: dstring.c =================================================================== --- dstring.c (revision 8016) +++ dstring.c (working copy) @@ -147,7 +147,7 @@ o = ds->len; while (1) { va_copy(ap, _ap); - n = vsnprintf(ds->str + o, ds->len+1 - o, format, ap); + n = _vsnprintf(ds->str + o, ds->len+1 - o, format, ap); va_end(ap); if (n > -1 && n+o <= ds->len) { if (n+o < ds->len) { @@ -186,7 +186,7 @@ if (ds) { while (1) { va_copy(ap, _ap); - n = vsnprintf(ds->str, ds->len+1, format, ap); + n = _vsnprintf(ds->str, ds->len+1, format, ap); va_end(ap); if (n > -1 && n <= ds->len) { if (n < ds->len) {
Regards Anders
Anders Broman wrote:
Hi, Would this patch work on unix it works for me on MSVC6:
Won't work with my linux+glibc. This is another case of M$ choosing to implement those standards that suit them. You could wrap them with "#ifdef _MSC_VER" or "#define vsnprintf _vsnprintf" in win.h.
MSVC8 gives lots of other "you should use _xxx instead of xxx" warnings.
The #define method is probably the simpler one, since it covers the entire build in one hit, and the same method would work for all the other warnings.
Index: dstring.c
--- dstring.c (revision 8016) +++ dstring.c (working copy) @@ -147,7 +147,7 @@ o = ds->len; while (1) { va_copy(ap, _ap);
n = vsnprintf(ds->str + o, ds->len+1 - o, format, ap);
n = _vsnprintf(ds->str + o, ds->len+1 - o, format, ap); va_end(ap); if (n > -1 && n+o <= ds->len) { if (n+o < ds->len) {
@@ -186,7 +186,7 @@ if (ds) { while (1) { va_copy(ap, _ap);
n = vsnprintf(ds->str, ds->len+1, format, ap);
n = _vsnprintf(ds->str, ds->len+1, format, ap); va_end(ap); if (n > -1 && n <= ds->len) { if (n < ds->len) {
Regards Anders
Hi, How about this then: C:\libsmi\trunk\win>svn diff Index: win.h =================================================================== --- win.h (revision 8019) +++ win.h (working copy) @@ -79,5 +79,7 @@ #if defined(_MSC_VER) #define strtof(f1,f2) ((float)strtod(f1,f2)) #endif + +#define vsnprintf _vsnprintf
#endif /* _WIN_H */
Index: tools/dstring.c =================================================================== --- tools/dstring.c (revision 8019) +++ tools/dstring.c (working copy) @@ -17,6 +17,11 @@ #include <string.h> #include <stdarg.h> #include <stdio.h> + +#ifdef HAVE_WIN_H +#include "win.h" +#endif + #include "dstring.h"
#if !defined va_copy
--------------- I also found: fprint.c ...\tools\fprint.c(52) : warning C4013: 'smiVasprintf' undefined; assuming extern returning int ...\tools\fprint.c(77) : warning C4018: '>' : signed/unsigned mismatch
Qured by:
Index: tools/fprint.c =================================================================== --- tools/fprint.c (revision 8019) +++ tools/fprint.c (working copy) @@ -25,6 +25,7 @@ #include "win.h" #endif
+#include "smi.h" #include "fprint.h"
Regards Anders
-----Original Message----- From: Andrew Hood [mailto:ajhood@fl.net.au] Sent: den 11 april 2008 00:14 To: libsmi@ibr.cs.tu-bs.de Cc: Anders Broman Subject: Re: [libsmi] Problem with vsnprintf and MSVC6
Anders Broman wrote:
Hi, Would this patch work on unix it works for me on MSVC6:
Won't work with my linux+glibc. This is another case of M$ choosing to implement those standards that suit them. You could wrap them with "#ifdef _MSC_VER" or "#define vsnprintf _vsnprintf" in win.h.
MSVC8 gives lots of other "you should use _xxx instead of xxx" warnings.
The #define method is probably the simpler one, since it covers the entire build in one hit, and the same method would work for all the other warnings.
Index: dstring.c
--- dstring.c (revision 8016) +++ dstring.c (working copy) @@ -147,7 +147,7 @@ o = ds->len; while (1) { va_copy(ap, _ap);
n = vsnprintf(ds->str + o, ds->len+1 - o, format, ap);
n = _vsnprintf(ds->str + o, ds->len+1 - o, format, ap); va_end(ap); if (n > -1 && n+o <= ds->len) { if (n+o < ds->len) {
@@ -186,7 +186,7 @@ if (ds) { while (1) { va_copy(ap, _ap);
n = vsnprintf(ds->str, ds->len+1, format, ap);
n = _vsnprintf(ds->str, ds->len+1, format, ap); va_end(ap); if (n > -1 && n <= ds->len) { if (n < ds->len) {
Regards Anders
-- There's no point in being grown up if you can't be childish sometimes. -- Dr. Who
On Fri, Apr 11, 2008 at 09:25:44AM +0200, Anders Broman wrote:
How about this then:
[...]
Applied (r8024).
/js
Juergen Schoenwaelder wrote:
On Fri, Apr 11, 2008 at 09:25:44AM +0200, Anders Broman wrote:
How about this then:
The attached patch shuts up all the ISO C++ deprecations warnings in MSVC8. (In CRLF format. You might want to convert to Unix format.)
It might take "#if _MSV_VER > something" for earlier versions like MSVC6. I don't have a copy of MSVC6. I could put MSCV7 on a VM to test it.
http://predef.sourceforge.net/precomp.html#sec32
has a list of appropriate values.
The file make.log has all the remaining MSVC8 errors. "size_t" being different to "int" seems to be the main complaint.
A potential danger is that (xxx *) and size_t could be 64 bit while int and unsigned could be 32 bit. Then (xxx *)a -(xxx *)b might not be 32 bit representable.
On Sun, Apr 13, 2008 at 12:06:53PM +1000, Andrew Hood wrote:
The attached patch shuts up all the ISO C++ deprecations warnings in MSVC8. (In CRLF format. You might want to convert to Unix format.)
It might take "#if _MSV_VER > something" for earlier versions like MSVC6. I don't have a copy of MSVC6. I could put MSCV7 on a VM to test it.
http://predef.sourceforge.net/precomp.html#sec32
has a list of appropriate values.
Is there not a better way to do this? I mean, things like strdup conform to SVr4, 4.3BSD, POSIX.1-2001 and is there really no way to with MSVC to say I want these functions even though they are not covered by ANSI C?
/js
Hi, I'm looking into changing the makefile ino a makefile more simmilar to Wiresharks(if thats ok?) In there different flags is used depending on MSVC version Like (configure.nmake in top dir) !IF "$(MSVC_VARIANT)" == "MSVC6" || "$(MSVC_VARIANT)" == "MSVC2002" || "$(MSVC_VARIANT)" == "DOTNET10" || "$(MSVC_VARIANT)" == "MSVC2003" || "$(MSVC_VARIANT)" == "DOTNET11" LOCAL_CFLAGS=/Zi /W3 /MD /DMSC_VER_REQUIRED=$(MSC_VER_REQUIRED) !ELSEIF "$(MSVC_VARIANT)" == "MSVC2005" || "$(MSVC_VARIANT)" == "MSVC2005EE" || "$(MSVC_VARIANT)" == "DOTNET20" || "$(MSVC_VARIANT)" == "MSVC2008EE" LOCAL_CFLAGS=/Zi /W3 /MD /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DMSC_VER_REQUIRED=$(MSC_VER_REQUIRED) !ELSE !ERROR MSVC_VARIANT unknown !ENDIF
which stops emmiting "deprecate" warnings I beleve if the warnings are the only problem that should do it. Regards Anders
________________________________
Från: libsmi-bounces@ibr.cs.tu-bs.de genom Juergen Schoenwaelder Skickat: ti 2008-04-15 16:28 Till: Andrew Hood Kopia: libsmi@ibr.cs.tu-bs.de Ämne: Re: [libsmi] Problem with vsnprintf and MSVC6
On Sun, Apr 13, 2008 at 12:06:53PM +1000, Andrew Hood wrote:
The attached patch shuts up all the ISO C++ deprecations warnings in MSVC8. (In CRLF format. You might want to convert to Unix format.)
It might take "#if _MSV_VER > something" for earlier versions like MSVC6. I don't have a copy of MSVC6. I could put MSCV7 on a VM to test it.
http://predef.sourceforge.net/precomp.html#sec32
has a list of appropriate values.
Is there not a better way to do this? I mean, things like strdup conform to SVr4, 4.3BSD, POSIX.1-2001 and is there really no way to with MSVC to say I want these functions even though they are not covered by ANSI C?
/js
-- Juergen Schoenwaelder Jacobs University Bremen gGmbH Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany Fax: +49 421 200 3103 http://www.jacobs-university.de/ -- !! This message is brought to you via the `libsmi' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to libsmi-request@ibr.cs.tu-bs.de !! or look at https://mail.ibr.cs.tu-bs.de/mailman/listinfo/libsmi.
participants (3)
-
Anders Broman
-
Andrew Hood
-
Juergen Schoenwaelder