On Tue, 14 Apr 2009 05:37:01 -0700, Deepika
<(E-Mail Removed)> wrote:
> Hi
> I am trying to do bluetooth programming on Microsoft Visual C++ 6.0.
> I am using basic functions like WSALookupServiceBegin().
> i wrote the code like this
> WSAQUERYSET wsaq;
> wsaq.dwNameSpace = NS_BTH;
>
> The problem is, the compiler is not recognising NS_BTH and giving compile
> time error.
>I included the following sets of headers and lib
>
> #include <winsock>
> #include <winsock2>
> #include <bthdef>
I guess your real code has the .h suffix on those header names?
> #include <BluetoothAPIs.h>
> #include <Ws2bth.h>
> #pragma comment(lib, "ws2_32.lib")
>
>The same goes with socket creation.
> Even if i am trying to create socket using the below code
>
> SOCKET client_socket = socket (AF_BT, SOCK_STREAM, BTHPROTO_RFCOMM);
>
> following error are coming up
>
> error C2065: 'NS_BTH' : undeclared identifier
> error C2065: 'AF_BT' : undeclared identifier
> error C2065: 'BTHPROTO_RFCOMM' : undeclared identifier
>
> i am not able to understand what else needs to be included.
>Is it because of Microsoft stack or some SDK is required?
According to this documentation, NS_BTH is declared in <winsock2.h>. If
your copy of that header does not contain it, you will need to update your
Platform SDK. If it does contain it, you will need to determine the
conditional compilation statement that is making it unavailable.
BTW, always #include <windows.h> first thing. There once was a really nifty
bug in <winsock2.h> that caused that header to change the struct packing
when it #included <windows.h> for you, and some headers aren't even
thoughtful enough to #include <windows.h> for you.
--
Doug Harrison
Visual C++ MVP
|