Hi Again,

> > Warnings are annoying, but having to add a random define is even more
> > so. What about adding two new configurations to the MSVC project. So
> > we'll have:
> >
> > Dynamic Debug
> > Dynamic Release
> > Static Debug
> > Static Release
> >
> > The latter two would have the constant defined.
> >
> > Thoughts?
> > Martin
> 
>       Yes, the separate projects answer is definitely preferable to me
> since you wouldn't be able to use the current projects for a static lib
> anyway.  I'm currently doing things this way in my little testbed app
> which
> I build projects for with premake4.  This just let's me verify dll/static
> builds, osx/linux etc without a lot of muckin about, not that I'm trying
> to
> push the premake stuff, it's just useful for quick x-plat test runs.

        So, I decided to do a quick test on this fix while I was running a
build at work.  It seems like there is a much easier fix for this; though we
would still want the additional configurations since it does still require
the definition added to the projects.

        Basically I missed the fact that the project files were using
non-compiler defined items and using standard "VC" inserted items.  What I
mean is that instead of looking for "_MSC_VER" to detect a vc compile, it
uses "_WIN32", and of course "DLL_EXPORT".  Those are not defined in the
compiler and are simply inserted if you use VC to generate the projects
using wizards.  Not a problem, that is likely the most common use case.

        Given this though, I suggest the following changes:

1.      Don't look for "_WIN32": use the guaranteed "_MSC_VER" so folks with
unique build requirements don't have to screw with adding an additional
definition to their projects.  I.e. "#if defined _MSC_VER" replaces "#if
defined _WIN32".  This is similar to using "__GNUC__", you know the compiler
defined it and unless someone is intentionally playing games, there should
never be a problem using that check.

2.      Still add in the check for "ZMQ_STATIC" so we can correct all the
link errors and warnings.  But, do it differently than I initially
mentioned.  I wasn't paying attention and missed the "DLL_EXPORT" usage.
That's another VC wizard inserted item, not a real compiler define.  But, it
does make things nice and easy, in a static build just define it.
Everything gets a "__declspec( dllexport )" which is fine and does not
generate any warnings it is the imports which cause the annoying warnings.

3.      Please move the checks into a different header so zmq.h and
zmq_utils.h can share the same behavior.  That messed me up a couple times
when I forgot to change one or the other. :)


        Those changes (minus #3, that's just cleanup) fix everything.  I.e.
here's the modified win32 import/export block:

#if defined _MSC_VER
#   if defined ZMQ_STATIC
#       define DLL_EXPORT
#   endif
#   if defined DLL_EXPORT
#       define ZMQ_EXPORT __declspec(dllexport)
#   else
#       define ZMQ_EXPORT __declspec(dllimport)
#   endif
#else
#   define ZMQ_EXPORT
#endif

        I'll add the static configs hopefully tomorrow..

KB

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to