Solved

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

Posted on 2012-03-17
3
1,926 Views
Last Modified: 2013-12-14
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

0
Comment
Question by:ichigokurosaki
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 37733027
Well, g++ is right - yet wrong as well. By using such a '#define'd struct, you are creating a temporary struct instance in all the statements above, thus passing a pointer to these functions. The point whre g++ is 'wrong' is simply that in these cases, this is an absolutely correct statement/operation and therefore the warning just does not matter - just ignore it.
0
 

Author Comment

by:ichigokurosaki
ID: 37733051
I solved it by using a variable to store the address. :)
0
 

Author Closing Comment

by:ichigokurosaki
ID: 37733058
jkr solution is fine, too!
i didn't see it before to close the question.

I want to assign the points to him.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question