Closed njh closed 8 years ago
Not so complicated :-) To have a visible eyecatcher to locate timestamp/broker version in the binary.
So it should stay then? 😀
Is there a way to make it as a known/special 'unused' variable?
This is what I see when compiling on Linux:
gcc -Wall -s -Os *.c -o broker
Broker.c: In function ‘main’:
Broker.c:252:15: warning: variable ‘broker_timestamp_eye’ set but not used [-Wunused-but-set-variable]
static char* broker_timestamp_eye = NULL;
^
Broker.c:251:15: warning: variable ‘broker_version_eye’ set but not used [-Wunused-but-set-variable]
static char* broker_version_eye = NULL;
^
The broker has the version in the console log:
njh@star:~/Projects/rsmb/rsmb/src$ ./broker
20160621 155052.711 CWNAN9999I Really Small Message Broker
20160621 155052.711 CWNAN9998I Part of Project Mosquitto in Eclipse
(http://projects.eclipse.org/projects/technology.mosquitto)
20160621 155052.712 CWNAN0053I Version 1.3.0.2, Jun 21 2016 15:48:56
20160621 155052.712 CWNAN0054I Features included: bridge
20160621 155052.713 CWNAN9993I Authors: Ian Craggs (icraggs@uk.ibm.com), Nicholas O'Leary
20160621 155052.713 CWNAN0075W Socket error 98 (Address already in use) in bind for socket 3
20160621 155052.713 CWNAN0078W Cannot bind port 1883
20160621 155052.713 CWNAN0015W Cannot start listener on port 1883
20160621 155052.713 CWNAN0016I MQTT protocol stopping
20160621 155052.714 CWNAN0044I Messages sent: 0
20160621 155052.714 CWNAN0043I Messages received: 0
20160621 155052.714 CWNAN0042I Uptime: 0 seconds
20160621 155052.714 CWNAN0055I Maximum heap use: 62896 bytes
20160621 155052.714 CWNAN0047I Broker stopped
Maybe add a --version
command line option instead?
I was asked to add the eyecatchers in the binary a long time ago. Some quick Googling came up with
attribute((unused))
to tell gcc to not produce the warning. (https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Variable-Attributes.html)
Will submit a PR that uses this:
#ifdef __GNUC__
#define ATTR_UNUSED __attribute__((unused))
#else
#define ATTR_UNUSED
#endif
Fixed this as part of PR #22
Hello,
I have been going through fixing compiler warnings and found these unused variables? In Broker.c / main():
Is it used for some kind of symbol extraction/debugging voodoo?
nick.