Skip to content

Commit

Permalink
defines to support older MSVC prior to 2010
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Trabant committed May 14, 2015
1 parent 6c7b764 commit a2d2dd6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2015.134: 2.16m
- Add defines for needed integer types and macros from inttypes.h
missing in older MSVC versions. MSVC 2010 and later appear to have
enough C99 support.
- Add define tests for _WIN32 and _WIN64 to cover all WINs.
- ms_fread(): Add cast to quiet warning for conversion from size_t
to int. In this case the read will always be <= MAXRECLEN, much
smaller than int, making the conversion safe.

2015.113: 2.16
- Update minor release version in Makefile.

Expand Down
2 changes: 1 addition & 1 deletion fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ ms_fread (char *buf, int size, int num, FILE *stream)
{
int read = 0;

read = fread (buf, size, num, stream);
read = (int) fread (buf, size, num, stream);

if ( read <= 0 && size && num )
{
Expand Down
4 changes: 2 additions & 2 deletions libmseed.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ extern "C" {

#include "lmplatform.h"

#define LIBMSEED_VERSION "2.16"
#define LIBMSEED_RELEASE "2015.113"
#define LIBMSEED_VERSION "2.16m"
#define LIBMSEED_RELEASE "2015.134"

#define MINRECLEN 128 /* Minimum Mini-SEED record length, 2^7 bytes */
/* Note: the SEED specification minimum is 256 */
Expand Down
29 changes: 26 additions & 3 deletions lmplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* Written by Chad Trabant, IRIS Data Management Center
*
* modified: 2015.108
* modified: 2015.134
***************************************************************************/

#ifndef LMPLATFORM_H
Expand Down Expand Up @@ -48,7 +48,6 @@ extern "C" {
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
Expand All @@ -59,25 +58,49 @@ extern "C" {
#define LMP_GLIBC2 1 /* Deprecated */

#include <unistd.h>
#include <inttypes.h>

#elif defined(__sun__) || defined(__sun)
#define LMP_SOLARIS 1

#include <unistd.h>
#include <inttypes.h>

#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define LMP_BSD 1

#include <unistd.h>
#include <inttypes.h>

#elif defined(WIN32) || defined(WIN64)
#elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
#define LMP_WIN 1
#define LMP_WIN32 1 /* Deprecated */

#include <windows.h>
#include <sys/types.h>

/* For pre-MSVC 2010 define standard int types, otherwise use inttypes.h */
#if defined(_MSC_VER) && _MSC_VER < 1600
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int int16_t;
typedef unsigned short int uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <inttypes.h>
#endif

#if defined(_MSC_VER)
#if !defined(PRId64)
#define PRId64 "I64d"
#endif
#if !defined(SCNd64)
#define SCNd64 "I64d"
#endif

#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strcasecmp _stricmp
Expand Down

0 comments on commit a2d2dd6

Please sign in to comment.