Odd error message...

S

SpreadTooThin

I am trying to figure out why I am getting this error:

I define a type in a header file. I include that file.
typedef struct x * xref;

I include it in my class

class myclass
{
xref xr;
};

I compile and get the error message:

error: 'xref' is used as a type, but is not defined as a type.

What is this?
 
V

Victor Bazarov

SpreadTooThin said:
I am trying to figure out why I am getting this error:

I define a type in a header file. I include that file.
typedef struct x * xref;

I include it in my class

class myclass
{
xref xr;
};

I compile and get the error message:

error: 'xref' is used as a type, but is not defined as a type.

Several possibilities. One, you claim to include that file,
but inclusion has no effects due to duplicate inclusion guards
(or other conditional compilation directive); solution -- make
your compiler output the preprocessing results and confirm you
actually have the definition of 'xref' in the scope. Two, how
is 'x' defined? Could it be it's a macro of sorts that screws
up the 'typedef' statement?

Anyway, read the FAQ 5.8 and follow its recommendations.

V
 
S

SpreadTooThin

Several possibilities. One, you claim to include that file,
but inclusion has no effects due to duplicate inclusion guards
(or other conditional compilation directive); solution -- make
your compiler output the preprocessing results and confirm you
actually have the definition of 'xref' in the scope.

Ok...
# 2762 "/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
IOBluetooth.framework/Headers/IOBluetoothUserLib.h" 3
typedef struct OpaqueIOBluetoothDeviceInquiryRef *
IOBluetoothDeviceInquiryRef;

Two, how is 'x' defined? Could it be it's a macro of sorts that screws
up the 'typedef' statement?

To be more accurate:

# 2762 "/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
IOBluetooth.framework/Headers/IOBluetoothUserLib.h" 3
typedef struct OpaqueIOBluetoothDeviceInquiryRef *
IOBluetoothDeviceInquiryRef;

I can find no other refrence to OpaqueIOBlueToothDeviceInquiryRef....
Anyway, read the FAQ 5.8 and follow its recommendations.

I Shall..

I also seem to be having issues with 'C' methods and defines...

extern "C" {
# 1 "/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
IOBluetooth.framework/Headers/IOBluetoothUserLib.h" 1 3

Yet the linker is saying:

bluetoothcontrol.cpp:56: error:
`IOBluetoothDeviceInquiryCreateWithCallbackRefCon' is not available
(declared at /Users/me/Desktop/development/plugins/bluetoothcontrol
bluetoothcontrol.cpp:52)

Tool:0: __Z48IOBluetoothDeviceInquiryCreateWithCallbackRefConPv

Checking the .i file:
# 2843 "/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
IOBluetooth.framework/Headers/IOBluetoothUserLib.h" 3
extern IOBluetoothDeviceInquiryRef
IOBluetoothDeviceInquiryCreateWithCallbackRefCon( void *
inUserRefCon ) __attribute__((unavailable));
 
V

Victor Bazarov

SpreadTooThin said:
Ok...
# 2762 "/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
IOBluetooth.framework/Headers/IOBluetoothUserLib.h" 3
typedef struct OpaqueIOBluetoothDeviceInquiryRef *
IOBluetoothDeviceInquiryRef;



To be more accurate:

# 2762 "/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
IOBluetooth.framework/Headers/IOBluetoothUserLib.h" 3
typedef struct OpaqueIOBluetoothDeviceInquiryRef *
IOBluetoothDeviceInquiryRef;

I can find no other refrence to OpaqueIOBlueToothDeviceInquiryRef....

Which suggests that 'OpaqueIOBluetoothDeviceInquiryRef' is declared
*right here* as a struct and a pointer to it is typedef'ed here,
*but* if it is not defined anywhere any attempt to dereference the
pointer would fail.

Check this out:

struct Blah;
typedef Blah *BlahPtr; // perfectly fine

class Foo {
BlahPtr ptr;
public:
Foo(BlahPtr p) : ptr(p) { ptr->doSomething(); } // error
};

struct Blah { void doSomething() {} };

int main() {
Blah blah;
Foo foo(&blah);
}

--------------------------------------- If I rewrite to have the
body of the Foo's c-tor after the definition of 'Blah', it should
be alright:

struct Blah;
typedef Blah *BlahPtr;

class Foo {
BlahPtr ptr;
public:
Foo(BlahPtr p); //
};

struct Blah { void doSomething() {} };

Foo::Foo(BlahPtr p) : ptr(p) { ptr->doSomething(); }

int main() {
Blah blah;
Foo foo(&blah);
}
===========================

Perhaps you were supposed to include some other header to provide
the definition of 'OpaqueIOBluetoothDeviceInquiryRef'...

Try RTFM.
I Shall..

I also seem to be having issues with 'C' methods and defines...

extern "C" {
# 1 "/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
IOBluetooth.framework/Headers/IOBluetoothUserLib.h" 1 3

Yet the linker is saying:

bluetoothcontrol.cpp:56: error:
`IOBluetoothDeviceInquiryCreateWithCallbackRefCon' is not available
(declared at /Users/me/Desktop/development/plugins/bluetoothcontrol
bluetoothcontrol.cpp:52)

Tool:0: __Z48IOBluetoothDeviceInquiryCreateWithCallbackRefConPv

Checking the .i file:
# 2843 "/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
IOBluetooth.framework/Headers/IOBluetoothUserLib.h" 3
extern IOBluetoothDeviceInquiryRef
IOBluetoothDeviceInquiryCreateWithCallbackRefCon( void *
inUserRefCon ) __attribute__((unavailable));

"__attribute__((unavailable))" -- you're beyond the Standard C++
territory. Perhaps asking about this thing in a MacOS newsgroup
would help...

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top