The macro is totally fine. There are always plenty of those to account for windows/*nix differences so it's not dirty by any means.
> On Jul 18, 2015, at 8:28 AM, Nick North <nort...@gmail.com> wrote: > > I see a couple of obvious solutions to this problem: > > > 1. Use the thread_local keyword rather than __thread. The semantics are > not identical, so @davisp may have views on whether the behaviour is still > OK. From the Windows build point of view, it would force us into building > with Visual Studio 2015, which releases on 20 Jul, so we don't know whether > it works with the rest of the build. > 2. Create a macro that expands to __declspec(thread) or __thread as > appropriate. This feels less correct than the thread_local solution, but > maybe better in the short term. > > Does anyone have any thoughts on which is the better way forward? Or have > alternative suggestions? > > Nick > >> On Fri, 17 Jul 2015 at 22:09 Nick North <nort...@gmail.com> wrote: >> >> Answering my own question: looks as if Microsoft uses __declspec(thread) >> rather than __thread. >> >> Nick >> >>> On Fri, 17 Jul 2015 at 22:02 Nick North <nort...@gmail.com> wrote: >>> >>> I'm trying out @wohali's Windows build, which went well up to compilation >>> of couch_ejson_compare.c, where it seems to be tripping up over the changes >>> in the recent commit >>> <https://github.com/apache/couchdb-couch/commit/6b38dfacbb97c5cb7c89a27115d1227c7c52dbba> >>> to optimise performance. Specifically it gives this series of errors: >>> >>> Compiling >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c >>> ERROR: compile failed while processing c:/couchdb/src/couch: rebar_abort >>> Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86 >>> Copyright (C) Microsoft Corporation. All rights reserved. >>> >>> cl : Command line warning D9002 : ignoring unknown option '-fno-common' >>> couch_ejson_compare.c >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(44) : >>> warnin >>> g C4431: missing type specifier - int assumed. Note: C no longer supports >>> defaul >>> t-int >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(44) : >>> error >>> C2054: expected '(' to follow '__thread' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(44) : >>> error >>> C2085: 'collator' : not in formal parameter list >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(44) : >>> error >>> C2143: syntax error : missing ';' before '=' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(58) : >>> warnin >>> g C4255: 'get_collator' : no function prototype given: converting '()' to >>> '(void >>> )' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(62) : >>> warnin >>> g C4255: 'get_collator' : no function prototype given: converting '()' to >>> '(void >>> )' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(66) : >>> error >>> C2065: 'collator' : undeclared identifier >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(66) : >>> warnin >>> g C4047: '!=' : 'int' differs in levels of indirection from 'void *' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(67) : >>> error >>> C2065: 'collator' : undeclared identifier >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(67) : >>> warnin >>> g C4047: 'return' : 'UCollator *' differs in levels of indirection from >>> 'int' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(70) : >>> error >>> C2065: 'collator' : undeclared identifier >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(70) : >>> warnin >>> g C4047: '=' : 'int' differs in levels of indirection from 'UCollator *' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(73) : >>> error >>> C2065: 'collator' : undeclared identifier >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(73) : >>> warnin >>> g C4047: 'function' : 'UCollator *' differs in levels of indirection from >>> 'int' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(73) : >>> warnin >>> g C4024: 'ucol_close_55' : different types for formal and actual >>> parameter 1 >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(78) : >>> error >>> C2065: 'collator' : undeclared identifier >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(78) : >>> warnin >>> g C4047: '=' : 'UCollator *' differs in levels of indirection from 'int' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(84) : >>> error >>> C2065: 'collator' : undeclared identifier >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(84) : >>> warnin >>> g C4047: 'return' : 'UCollator *' differs in levels of indirection from >>> 'int' >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(256) >>> : warni >>> ng C4127: conditional expression is constant >>> c:/couchdb/src/couch/priv/couch_ejson_compare/couch_ejson_compare.c(296) >>> : warni >>> ng C4127: conditional expression is constant >>> >>> I'll look into this further tomorrow, but someone more knowledgeable may >>> immediately know what the problem is and be able to suggest a solution. >>> >>> Nick >>> >>> >>>