Skip to content

Commit

Permalink
chore: adapt to MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Apr 7, 2024
1 parent 3ee1239 commit a254c8f
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions base16384.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,18 @@ typedef enum base16384_err_t base16384_err_t;

#ifdef _MSC_VER
#include <BaseTsd.h>
#ifndef ssize_t
#define SSIZE_T ssize_t;
#endif
#endif

#ifdef _MSC_VER
/**
* @brief custom reader function interface
* @param client_data the data pointer defined by the client
* @param buffer to where put data
* @param count read bytes count
* @return the size read
*/
typedef SSIZE_T (*base16384_reader_t)(const void *client_data, void *buffer, size_t count);
#else
/**
* @brief custom reader function interface
* @param client_data the data pointer defined by the client
Expand All @@ -74,7 +81,18 @@ typedef enum base16384_err_t base16384_err_t;
* @return the size read
*/
typedef ssize_t (*base16384_reader_t)(const void *client_data, void *buffer, size_t count);
#endif

#ifdef _MSC_VER
/**
* @brief custom writer function interface
* @param client_data the data pointer defined by the client
* @param buffer from where read data
* @param count write bytes count
* @return the size written
*/
typedef SSIZE_T (*base16384_writer_t)(const void *client_data, const void *buffer, size_t count);
#else
/**
* @brief custom writer function interface
* @param client_data the data pointer defined by the client
Expand All @@ -83,11 +101,6 @@ typedef ssize_t (*base16384_reader_t)(const void *client_data, void *buffer, siz
* @return the size written
*/
typedef ssize_t (*base16384_writer_t)(const void *client_data, const void *buffer, size_t count);

#ifdef _MSC_VER
#ifdef ssize_t
#undef ssize_t
#endif
#endif

union base16384_io_function_t {
Expand Down

0 comments on commit a254c8f

Please sign in to comment.