[Live-devel] Annoying "C" Linkage Problem under MSVC - _close()
Ben Lear
benlear at benlear.com
Sat Apr 16 10:36:34 PDT 2005
Hey List,
Finally got around to implementing some custom classes to stream MPEG4 A/V
directly from an encoder. In doing so I ran into an annoying problem where
MSVC whined about "a second C Linkage" of the _close(int) function.
Looking at the code it is plain to see that _close is redefined in
NetCommon.h depending on linux or windows compile. This is done as you
cannot "close()" a socket in windows as you can in linux, as files and
socket FD's are not interchangable. This redefining is fine in principle,
however _close() *IS* actually a defined windows system function call (it
closes a file handle :|) and therefore IMHO we should *NOT* use this name.
In my local tree I changed this define to be:
// windows
#define CloseSocket closesocket
// Linux
#define CloseSocket close
And replaced all instances of _close with CloseSocket
My problem of "Multiple C Linkage" went away and I now feel more comfortable
with a cleaner namespace :)
Cheers,
Ben.
More information about the live-devel
mailing list