Tor fails to build with MSVC
Reported by Gisle Vanem on tor-dev@ https://lists.torproject.org/pipermail/tor-dev/2023-March/014825.html:
Trying to compile Tor with 'cl' ver. 19.36.32323 from
yesterdays 'git master', I got this error in
'src/feature/hs/hs_metrics_entry.c':
hs/hs_metrics_entry.c(98,3): error C2099: initializer is not a constant
{
^
hs/hs_metrics_entry.c(106,3): error C2099: initializer is not a constant
{
^
----------
This MSVC compiler is rather stupid; it fails to parse that
'static const size_t hs_metrics_circ_build_time_buckets_size'
is truly 'const'. No problem with 'clang-cl'.
But this patch works:
--- a/feature/hs/hs_metrics_entry.c 2023-03-17 18:00:57
+++ b/feature/hs/hs_metrics_entry.c 2023-03-18 13:56:58
@@ -28,8 +28,7 @@
60000 /* 60s */
};
-static const size_t hs_metrics_circ_build_time_buckets_size =
- ARRAY_LENGTH(hs_metrics_circ_build_time_buckets);
+#define hs_metrics_circ_build_time_buckets_size ARRAY_LENGTH(hs_metrics_circ_build_time_buckets)
-----------------