Hi,

On Fri, 2006-07-21 at 07:59 -0500, Patrick Hartling wrote:
> A recent change to Source/Base/Base/OSGBaseFunctions.inl added the function
> osgGetHostname(), which calls gethostname(). On Windows, the gethostname()
> function is declared in winsock.h, which is included by windows.h, which is
> included by OSGConfig.h. However, winsock.h is not included if the
> preprocessor symbol WIN32_LEAN_AND_MEAN is defined. This means that any code
> compiling against OpenSG that defines WIN32_LEAN_AND_MEAN before OSGConfig.h
> is included now fails to compile because gethostname() isn't declared.
> 
> A fairly easy way to avoid this problem is to include winsock.h explicitly
> after windows.h is included in OSGConfig.h. Of course, it looks as though
> there is the potential for the inclusion of windows.h by OSGConfig.h to be
> prevented through the use of other preprocessor symbols, so there are other
> ways for things to break. I am not sure what the circumstances are where
> OSG_NO_WINDOWD_H_INCLUDE would be defined, and perhaps that is only for
> internal use by OpenSG. Another way to work around this is to have
> user-level code include windows.h and winsock.h before any OpenSG headers
> are included, but that seems impractical. The last option that I can think
> of is to move the implementation of osgGetHostname() into
> OSGBaseFunctions.cpp, but that still leaves open the possibility of other
> compile failures in the future when WIN32_LEAN_AND_MEAN is defined.
> 
> Are there other ways of handling this?

besides

#ifdef WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN
#endif 

in OSGConfig.h ;-)

my favorite would be to make OpenSG use WIN32_LEAN_AND_MEAN as my hope 
would be that if it works with this define set it should work without
it. The other way round does not seem to work. The reason we had not to
use WIN32_LEAN_AND_MEAN was that the MS winsock headers were not
guarded properly so depending on your include order of windows.h,
winsock.h and winsock2.h the compilation could fail. But this might
have changed with more recent compiler versions. I'll give it a try
once I'm in front of a windows machine again.

regards,
  gerrit





-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to