Avatar of ichigokurosaki
ichigokurosaki
Flag for Afghanistan asked on

[C, C++] BlueZ Bluetooth BDADDR_ANY warning for address of temporary

I'm having some problems with g++ and the compiling process for a C/C++ program which use Bluetooth libraries under Ubuntu.

If i use gcc, it works fine with no warning; on the contrary, if i use g++ i get this warning:
warning: taking address of temporary
even if the program compiles fine and it works.

The involved lines reporting the error are:

        bdaddr_t *inquiry(){
       // do some stuff.. 
	bacpy(&result[mote++], BDADDR_ANY);
	return result;
}
//...
void zeemote(){
while (bacmp(bdaddr, BDADDR_ANY)){
/..
}
}

Open in new window


In both the cases, BDADDR_ANY is involved.
How can i solve this warning?
BDADDR_ANY is defined in bluetooth.h like:
/* BD Address */
typedef struct {
	uint8_t b[6];
} __attribute__((packed)) bdaddr_t;

#define BDADDR_ANY   (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})

Open in new window

Wireless NetworkingC++C

Avatar of undefined
Last Comment
ichigokurosaki

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jkr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ichigokurosaki

ASKER
I solved it by using a variable to store the address. :)
ichigokurosaki

ASKER
jkr solution is fine, too!
i didn't see it before to close the question.

I want to assign the points to him.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck