This gcc-centric macro in or/config.c doesn't work well in MSVC v16/18:
#define COMPLAIN(args...) \ STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
I suggest it should be patched like this:
--- a/config.c 2015-05-06 22:22:09 +0000 +++ b/config.c 2015-05-06 23:15:57 +0000 @@ -2571,8 +2571,8 @@
#define REJECT(arg) \ STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END -#define COMPLAIN(args...) \ - STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END +#define COMPLAIN(args, ...) \ + STMT_BEGIN log_warn(LD_CONFIG, args, ## __VA_ARGS__); STMT_END
/** Log a warning message iff <b>filepath</b> is not absolute. * Warning message must contain option name <b>option</b> and
-------
All recent compilers supports '__VA_ARGS__'?
Ping list?
Gisle Vanem wrote:
This gcc-centric macro in or/config.c doesn't work well in MSVC v16/18:
#define COMPLAIN(args...) \ STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
Even MSVC v19 doesn't have such preprocessor magic. It's gcc specific and not C99 I guess. Can you please use '__VA_ARGS__' instead? Something like:
#define REJECT(arg) \ STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END -#define COMPLAIN(args...) \
- STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
+#define COMPLAIN(args, ...) \
- STMT_BEGIN log_warn(LD_CONFIG, args, ## __VA_ARGS__); STMT_END
Hello Gisle,
I will look into this later this week. Do you use the workflow in building-tor-msvc.txt to build tor on Windows?
2015-07-10 14:15, Gisle Vanem rašė:
Ping list?
Gisle Vanem wrote:
This gcc-centric macro in or/config.c doesn't work well in MSVC v16/18:
#define COMPLAIN(args...) \ STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
Even MSVC v19 doesn't have such preprocessor magic. It's gcc specific and not C99 I guess. Can you please use '__VA_ARGS__' instead? Something like:
#define REJECT(arg) \ STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END -#define COMPLAIN(args...) \
- STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
+#define COMPLAIN(args, ...) \
- STMT_BEGIN log_warn(LD_CONFIG, args, ## __VA_ARGS__); STMT_END
On Tue, May 19, 2015 at 3:20 PM, Gisle Vanem gvanem@yahoo.no wrote:
This gcc-centric macro in or/config.c doesn't work well in MSVC v16/18:
#define COMPLAIN(args...) \ STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
I suggest it should be patched like this:
--- a/config.c 2015-05-06 22:22:09 +0000 +++ b/config.c 2015-05-06 23:15:57 +0000 @@ -2571,8 +2571,8 @@
#define REJECT(arg) \ STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END -#define COMPLAIN(args...) \
- STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
+#define COMPLAIN(args, ...) \
- STMT_BEGIN log_warn(LD_CONFIG, args, ## __VA_ARGS__); STMT_END
I just applied something like this to master, and made corresponding changes to torlog.h as well.
I made the changes conditional on not having GCC, since the GCC syntax will work with older versions of GCC. (Somebody should check whether we care about those versions.)
Thanks!
Nick Mathewson wrote:
I made the changes conditional on not having GCC, since the GCC syntax will work with older versions of GCC. (Somebody should check whether we care about those versions.)
I saw that; from the Changelog:
o Minor features (portability): - Use C99 variadic macros when the compiler is not GCC. This avoids failing compilations on MSVC, and fixes a log-file-based race condition in our old workarounds. Original patch from Gisle Vanem.
I don't know what the "race conditions" is about, but this (?) change broke MSVC again by a '__PRETTY_FUNCTION__' which MSVC doesn't have. I suggest you add a: #define __PRETTY_FUNCTION__ __FUNCTION__
to win32/orconfig.h.
Trying to find the change under https://trac.torproject.org/projects/tor/browse proved impossible. That site is so slow so I add some more MSVC-porting issues here:
1) Base-types like 'uint8_t' have been part of MSVC's <stdint.h> since ver. 1600. So this patch was needed here:
--- a/src/ext/trunnel/trunnel-impl.h 2015-06-04 19:32:02 +0000 +++ b/ext/trunnel/trunnel-impl.h 2015-06-04 19:49:06 +0000 @@ -18,7 +18,7 @@ #include "trunnel-local.h" #endif
-#ifdef _MSC_VER +#if defined(_MSC_VER) && (_MSC_VER < 1600) #define uint8_t unsigned char #define uint16_t unsigned short #define uint32_t unsigned int
2) MSVC have never had <dirent.h>:
--- a/src/test/test_checkdir.c 2015-03-03 20:36:19 +0000 +++ b/src/test/test_checkdir.c 2015-03-04 15:29:02 +0000 @@ -3,7 +3,11 @@
#include "orconfig.h" #include "or.h" + +#ifndef _MSC_VER #include <dirent.h> +#endif + #include "config.h" #include "test.h" #include "util.h"
On Fri, Jul 17, 2015 at 6:32 AM, Gisle Vanem gvanem@yahoo.no wrote:
Nick Mathewson wrote:
I made the changes conditional on not having GCC, since the GCC syntax
will work with older versions of GCC. (Somebody should check whether we care about those versions.)
Thanks for the info!
I saw that; from the Changelog:
o Minor features (portability): - Use C99 variadic macros when the compiler is not GCC. This avoids failing compilations on MSVC, and fixes a log-file-based race condition in our old workarounds. Original patch from Gisle Vanem.
I don't know what the "race conditions" is about, but this (?) change broke MSVC again by a '__PRETTY_FUNCTION__' which MSVC doesn't have. I suggest you add a: #define __PRETTY_FUNCTION__ __FUNCTION__
to win32/orconfig.h.
I've changed the non-__GNUC__ case to use __FUNCTION__ unconditionally, since __PRETTY_FUNCTION__ is a GCC extension.
Trying to find the change under https://trac.torproject.org/projects/tor/browse proved impossible. That site is so slow so I add some more MSVC-porting issues here:
Instead I'd recommend https://gitweb.torproject.org/tor.git/
- Base-types like 'uint8_t' have been part of MSVC's <stdint.h>
since ver. 1600. So this patch was needed here:
--- a/src/ext/trunnel/trunnel-impl.h 2015-06-04 19:32:02 +0000 +++ b/ext/trunnel/trunnel-impl.h 2015-06-04 19:49:06 +0000 @@ -18,7 +18,7 @@ #include "trunnel-local.h" #endif
-#ifdef _MSC_VER +#if defined(_MSC_VER) && (_MSC_VER < 1600) #define uint8_t unsigned char #define uint16_t unsigned short #define uint32_t unsigned int
I've applied this to trunnel!
- MSVC have never had <dirent.h>:
--- a/src/test/test_checkdir.c 2015-03-03 20:36:19 +0000 +++ b/src/test/test_checkdir.c 2015-03-04 15:29:02 +0000 @@ -3,7 +3,11 @@
#include "orconfig.h" #include "or.h"
+#ifndef _MSC_VER #include <dirent.h> +#endif
#include "config.h" #include "test.h" #include "util.h"
Thanks, fixed. Is it working better now?