Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2012-03-17
3
Medium Priority
?
2,056 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 2000 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

Introducing the WatchGuard 420 Access Point

WatchGuard's newest access point includes an 802.11ac Wave 2 chipset, providing the fastest speeds for VoIP, video and music streaming, and large data file transfers. Additionally, enjoy the benefits of strong security as the 3rd radio delivers dedicated WIPS protection!

Question has a verified solution.

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

Tired of waiting for your show or movie to load?  Are buffering issues a constant problem with your internet connection?  Check this article out to see if these simple adjustments are the solution for you.
This program is used to assist in finding and resolving common problems with wireless connections.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

722 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