Commit 3fb246237df40e25ed9e1c24a34c0779778e79e6
1 parent
e6349372
Fix compilation issue with Microsoft Visual Studio 2008
Reported by Allan Cornet.
Showing
9 changed files
with
35 additions
and
4 deletions
README.rst
| @@ -26,6 +26,9 @@ Installation | @@ -26,6 +26,9 @@ Installation | ||
| 26 | 26 | ||
| 27 | The shell commands are ``./autogen.sh; ./configure; make; make install``. | 27 | The shell commands are ``./autogen.sh; ./configure; make; make install``. |
| 28 | 28 | ||
| 29 | +If you want to compile with Microsoft Visual Studio, you need to install | ||
| 30 | +http://code.google.com/p/msinttypes/ to fill the absence of stdint.h. | ||
| 31 | + | ||
| 29 | Testing | 32 | Testing |
| 30 | ------- | 33 | ------- |
| 31 | 34 |
src/modbus-data.c
| @@ -16,7 +16,11 @@ | @@ -16,7 +16,11 @@ | ||
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include <stdlib.h> | 18 | #include <stdlib.h> |
| 19 | +#ifndef _MSC_VER | ||
| 19 | #include <stdint.h> | 20 | #include <stdint.h> |
| 21 | +#else | ||
| 22 | +#include "stdint.h" | ||
| 23 | +#endif | ||
| 20 | #include <string.h> | 24 | #include <string.h> |
| 21 | #include <assert.h> | 25 | #include <assert.h> |
| 22 | #include <netinet/in.h> | 26 | #include <netinet/in.h> |
src/modbus-private.h
| @@ -18,11 +18,16 @@ | @@ -18,11 +18,16 @@ | ||
| 18 | #ifndef _MODBUS_PRIVATE_H_ | 18 | #ifndef _MODBUS_PRIVATE_H_ |
| 19 | #define _MODBUS_PRIVATE_H_ | 19 | #define _MODBUS_PRIVATE_H_ |
| 20 | 20 | ||
| 21 | -#include <sys/time.h> | 21 | +#ifndef _MSC_VER |
| 22 | +# include <stdint.h> | ||
| 23 | +# include <sys/time.h> | ||
| 24 | +#else | ||
| 25 | +# include "stdint.h" | ||
| 26 | +# include <time.h> | ||
| 27 | +#endif | ||
| 22 | #include <sys/types.h> | 28 | #include <sys/types.h> |
| 23 | -#include <stdint.h> | ||
| 24 | - | ||
| 25 | #include <config.h> | 29 | #include <config.h> |
| 30 | + | ||
| 26 | #include "modbus.h" | 31 | #include "modbus.h" |
| 27 | 32 | ||
| 28 | MODBUS_BEGIN_DECLS | 33 | MODBUS_BEGIN_DECLS |
src/modbus-rtu-private.h
| @@ -18,7 +18,11 @@ | @@ -18,7 +18,11 @@ | ||
| 18 | #ifndef _MODBUS_RTU_PRIVATE_H_ | 18 | #ifndef _MODBUS_RTU_PRIVATE_H_ |
| 19 | #define _MODBUS_RTU_PRIVATE_H_ | 19 | #define _MODBUS_RTU_PRIVATE_H_ |
| 20 | 20 | ||
| 21 | +#ifndef _MSC_VER | ||
| 21 | #include <stdint.h> | 22 | #include <stdint.h> |
| 23 | +#else | ||
| 24 | +#include "stdint.h" | ||
| 25 | +#endif | ||
| 22 | 26 | ||
| 23 | #if defined(_WIN32) | 27 | #if defined(_WIN32) |
| 24 | #include <windows.h> | 28 | #include <windows.h> |
src/modbus-rtu.c
| @@ -20,7 +20,9 @@ | @@ -20,7 +20,9 @@ | ||
| 20 | #include <errno.h> | 20 | #include <errno.h> |
| 21 | #include <fcntl.h> | 21 | #include <fcntl.h> |
| 22 | #include <string.h> | 22 | #include <string.h> |
| 23 | +#ifndef _MSC_VER | ||
| 23 | #include <unistd.h> | 24 | #include <unistd.h> |
| 25 | +#endif | ||
| 24 | #include <assert.h> | 26 | #include <assert.h> |
| 25 | 27 | ||
| 26 | #include "modbus-private.h" | 28 | #include "modbus-private.h" |
src/modbus-tcp.c
| @@ -19,7 +19,9 @@ | @@ -19,7 +19,9 @@ | ||
| 19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
| 20 | #include <string.h> | 20 | #include <string.h> |
| 21 | #include <errno.h> | 21 | #include <errno.h> |
| 22 | +#ifndef _MSC_VER | ||
| 22 | #include <unistd.h> | 23 | #include <unistd.h> |
| 24 | +#endif | ||
| 23 | #include <signal.h> | 25 | #include <signal.h> |
| 24 | #include <sys/types.h> | 26 | #include <sys/types.h> |
| 25 | 27 |
src/modbus.c
| @@ -22,7 +22,9 @@ | @@ -22,7 +22,9 @@ | ||
| 22 | #include <stdio.h> | 22 | #include <stdio.h> |
| 23 | #include <string.h> | 23 | #include <string.h> |
| 24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
| 25 | +#ifndef _MSC_VER | ||
| 25 | #include <unistd.h> | 26 | #include <unistd.h> |
| 27 | +#endif | ||
| 26 | #include <errno.h> | 28 | #include <errno.h> |
| 27 | #include <limits.h> | 29 | #include <limits.h> |
| 28 | 30 |
src/modbus.h
| @@ -23,8 +23,13 @@ | @@ -23,8 +23,13 @@ | ||
| 23 | #include <sys/param.h> | 23 | #include <sys/param.h> |
| 24 | #endif | 24 | #endif |
| 25 | 25 | ||
| 26 | +#ifndef _MSC_VER | ||
| 26 | #include <stdint.h> | 27 | #include <stdint.h> |
| 27 | #include <sys/time.h> | 28 | #include <sys/time.h> |
| 29 | +#else | ||
| 30 | +#include "stdint.h" | ||
| 31 | +#include <time.h> | ||
| 32 | +#endif | ||
| 28 | 33 | ||
| 29 | #include "modbus-version.h" | 34 | #include "modbus-version.h" |
| 30 | 35 |
tests/unit-test.h
| @@ -24,7 +24,11 @@ | @@ -24,7 +24,11 @@ | ||
| 24 | #include <inttypes.h> | 24 | #include <inttypes.h> |
| 25 | #endif | 25 | #endif |
| 26 | #ifdef HAVE_STDINT_H | 26 | #ifdef HAVE_STDINT_H |
| 27 | -#include <stdint.h> | 27 | +# ifndef _MSC_VER |
| 28 | +# include <stdint.h> | ||
| 29 | +# else | ||
| 30 | +# include "stdint.h" | ||
| 31 | +# endif | ||
| 28 | #endif | 32 | #endif |
| 29 | 33 | ||
| 30 | #define SERVER_ID 17 | 34 | #define SERVER_ID 17 |