Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

VC7 compile/build problems (was DNSServiceQueryRecord)



I'm finally trying to port my test code to Windows
(working now on OS X, Linux, FreeBSD, and Solaris).

But I seem to be having problems with the function
pointer callback typedefs in dnssd.h.

For example, with DNSServiceRegister(Reply), I get the
following errors:

server.c(185): warning C4024: 'DNSServiceRegister' :
different types for formal and actual parameter 11

server.c(185): error C2440: 'function' : cannot
convert from 'void (__cdecl
*)(DNSServiceRef,DNSServiceFlags,DNSServiceErrorType,const
char *,const char *,const char *,void *)' to
'DNSServiceRegisterReply'


I looked through the dnssd.h header and found this:

// standard calling convention under Win32 is
__stdcall
#if defined(_WIN32)
#	define DNSSD_API	__stdcall
#else
#	define DNSSD_API
#endif

If I remove the define to __stdcall (and define it to
nothing), then my code compiles.

However, at that point, I fail the link process:

error LNK2019: unresolved external symbol
_DNSServiceRegister referenced in function _main
error LNK2019: unresolved external symbol
_DNSServiceProcessResult referenced in function _main
error LNK2019: unresolved external symbol
_DNSServiceRefDeallocate referenced in function _main
error LNK2019: unresolved external symbol
_DNSServiceRefSockFD referenced in function _main

So I figured removing the __stdcall was probably
causing the link failures. So I went back, and
restored the __stdcall, but in every typedef
definition for a function pointer, I removed the
__stdcall from there.

For example:
typedef void (DNSSD_API *DNSServiceResolveReply)
becomes
typedef void (*DNSServiceResolveReply)

This seemed to work and my program builds. I'm not
totally sure about the correctness in doing this
though.

So is there a better way to avoid these compile/build
problems without modifying the dnssd.h header? Perhaps
there's a different way to write function pointer code
than what I'm doing? My stuff is pretty boring though:

void reply_callback(
	DNSServiceRef sdref, 
	DNSServiceFlags flags, 
	DNSServiceErrorType error,
	const char* name,
	const char* regtype,
	const char* domain,
	void* context) 
{
	fprintf(stderr, "In RegisterReply callback: flags=%d,
error=%d\n\tname=%s\n\tregtype=%s\n\tdomain=%s\n",
flags, error, name, regtype, domain);
}

dns_error = DNSServiceRegister(
			&service_ref,  
			0,  						  * if there is a conflict */
			0,  
			"Mytalk", 
			"_http._tcp.", 
			NULL,  
			NULL, 
			chosen_port, 
			0,  
			NULL, 
			reply_callback, 
			NULL 
		);

If not, I would be happy to send my modified header
file for inclusion into the standard code base if the
changes are deemed correct.

I'm using Visual Studio .NET 2003. I'm using the
Rendezvous SDK technology preview. (I didn't build
this myself.) The dnssd.h header version is 1.22 which
seems .01 less than my CVS version (which talks about
FreeBSD fixes), so I'm expecting (hoping) my stuff to
be current enough without me having to build it.

Thanks,
Eric
_______________________________________________
rendezvous mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/rendezvous
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.