Skip to content

Commit

Permalink
Use c99 as compiling standard.
Browse files Browse the repository at this point in the history
Closes: #765.
  • Loading branch information
ralight committed Apr 5, 2018
1 parent c3314fd commit 40e6a75
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions client/client_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and the Eclipse Distribution License is available at
Roger Light - initial implementation and documentation.
*/

#define _POSIX_C_SOURCE 200809L

#include <errno.h>
#include <fcntl.h>
Expand All @@ -22,6 +23,7 @@ and the Eclipse Distribution License is available at
#include <string.h>
#ifndef WIN32
#include <unistd.h>
#include <strings.h>
#else
#include <process.h>
#include <winsock2.h>
Expand Down
9 changes: 7 additions & 2 deletions client/pub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ and the Eclipse Distribution License is available at
Roger Light - initial implementation and documentation.
*/

/* For nanosleep */
#define _POSIX_C_SOURCE 200809L

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#include <unistd.h>
#include <time.h>
#else
#include <process.h>
#include <winsock2.h>
Expand Down Expand Up @@ -442,7 +444,10 @@ int main(int argc, char *argv[])
#ifdef WIN32
Sleep(100);
#else
usleep(100000);
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 100000000;
nanosleep(&ts, NULL);
#endif
}
rc = MOSQ_ERR_SUCCESS;
Expand Down
2 changes: 2 additions & 0 deletions client/sub_client_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and the Eclipse Distribution License is available at
Roger Light - initial implementation and documentation.
*/

#define _POSIX_C_SOURCE 199309L

#include <assert.h>
#include <errno.h>
#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
#define uthash_malloc(sz) mosquitto__malloc(sz)
#define uthash_free(ptr,sz) mosquitto__free(ptr)

#define _POSIX_C_SOURCE 200809L
6 changes: 3 additions & 3 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ else
CFLAGS?=-Wall -ggdb -O2
endif

LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib
LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib -std=c99
LIB_CXXFLAGS:=$(LIB_CFLAGS) ${CPPFLAGS}
LIB_LDFLAGS:=${LDFLAGS}

BROKER_CFLAGS:=${LIB_CFLAGS} ${CPPFLAGS} -DVERSION="\"${VERSION}\"" -DWITH_BROKER
CLIENT_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I../lib -DVERSION="\"${VERSION}\""
BROKER_CFLAGS:=${LIB_CFLAGS} ${CPPFLAGS} -DVERSION="\"${VERSION}\"" -DWITH_BROKER -std=c99
CLIENT_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I../lib -DVERSION="\"${VERSION}\"" -std=c99

ifneq ($(or $(findstring $(UNAME),FreeBSD), $(findstring $(UNAME),OpenBSD)),)
BROKER_LIBS:=-lm
Expand Down
5 changes: 3 additions & 2 deletions lib/mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ and the Eclipse Distribution License is available at
Roger Light - initial implementation and documentation.
*/

#include "config.h"

#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#ifndef WIN32
#include <strings.h>
#include <sys/select.h>
#include <sys/time.h>
#include <unistd.h>
Expand All @@ -45,8 +48,6 @@ typedef int ssize_t;
#include "util_mosq.h"
#include "will_mosq.h"

#include "config.h"

#if !defined(WIN32) && !defined(__SYMBIAN32__)
#define HAVE_PSELECT
#endif
Expand Down
2 changes: 2 additions & 0 deletions lib/time_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and the Eclipse Distribution License is available at
Roger Light - initial implementation and documentation.
*/

#include "config.h"

#ifdef __APPLE__
#include <mach/mach.h>
#include <mach/mach_time.h>
Expand Down
3 changes: 3 additions & 0 deletions lib/tls_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ and the Eclipse Distribution License is available at

#ifdef WITH_TLS

#include "config.h"

#ifdef WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
#else
# include <arpa/inet.h>
# include <sys/socket.h>
# include <strings.h>
#endif

#include <string.h>
Expand Down
4 changes: 2 additions & 2 deletions src/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and the Eclipse Distribution License is available at
Roger Light - initial implementation and documentation.
*/

#include "config.h"

#include <assert.h>
#include <errno.h>
#include <stdio.h>
Expand All @@ -27,8 +29,6 @@ and the Eclipse Distribution License is available at
#include <ws2tcpip.h>
#endif

#include "config.h"

#include "mosquitto.h"
#include "mosquitto_broker_internal.h"
#include "mosquitto_internal.h"
Expand Down
3 changes: 2 additions & 1 deletion src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and the Eclipse Distribution License is available at
Roger Light - initial implementation and documentation.
*/

#include <config.h>
#include "config.h"

#include <limits.h>
#include <stdio.h>
Expand All @@ -25,6 +25,7 @@ and the Eclipse Distribution License is available at
#ifdef WIN32
#else
# include <dirent.h>
# include <strings.h>
#endif

#ifndef WIN32
Expand Down
1 change: 1 addition & 0 deletions src/conf_includedir.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and the Eclipse Distribution License is available at
#endif

#ifndef WIN32
# include <strings.h>
# include <netdb.h>
# include <sys/socket.h>
#else
Expand Down
2 changes: 2 additions & 0 deletions src/mosquitto_passwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and the Eclipse Distribution License is available at
Roger Light - initial implementation and documentation.
*/

#define _POSIX_C_SOURCE 200809L
#define _BSD_SOURCE

#include <errno.h>
#include <openssl/evp.h>
Expand Down
Binary file removed test/broker/c/auth_plugin_v2.so
Binary file not shown.

0 comments on commit 40e6a75

Please sign in to comment.