Merge pull request #444 from michaeltryby/dev

Cleaning up build on gcc
This commit is contained in:
Michael Tryby
2019-04-03 10:58:46 -04:00
committed by GitHub
6 changed files with 19 additions and 21 deletions

View File

@@ -11,13 +11,9 @@
****************************************************************************** ******************************************************************************
*/ */
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifndef __APPLE__
#include <malloc.h>
#else
#include <stdlib.h>
#endif
//*** For the Windows SDK _tempnam function ***// //*** For the Windows SDK _tempnam function ***//
#ifdef _WIN32 #ifdef _WIN32

View File

@@ -58,12 +58,12 @@ void delete_file_manager(file_handle_t *file_handle) {
} }
void get_filename(file_handle_t *file_handle, char **filename, size_t *size) int get_filename(file_handle_t *file_handle, char **filename)
// //
// BE AWARE: The memory allocated here must be freed by the caller // BE AWARE: The memory allocated here must be freed by the caller
// //
{ {
copy_cstr(file_handle->filename, filename); return copy_cstr(file_handle->filename, filename);
} }
@@ -86,7 +86,7 @@ int open_file(file_handle_t *file_handle, const char *filename, const char *file
int seek_file(file_handle_t *file_handle, F_OFF offset, int whence) int seek_file(file_handle_t *file_handle, F_OFF offset, int whence)
{ {
#ifdef _WIN32 // Windows (32-bit and 64-bit) #ifdef _MSC_VER // Windows (32-bit and 64-bit)
#define FSEEK64 _fseeki64 #define FSEEK64 _fseeki64
#else // Other platforms #else // Other platforms
#define FSEEK64 fseeko #define FSEEK64 fseeko
@@ -97,7 +97,7 @@ int seek_file(file_handle_t *file_handle, F_OFF offset, int whence)
F_OFF tell_file(file_handle_t *file_handle) F_OFF tell_file(file_handle_t *file_handle)
{ {
#ifdef _WIN32 // Windows (32-bit and 64-bit) #ifdef _MSC_VER // Windows (32-bit and 64-bit)
#define FTELL64 _ftelli64 #define FTELL64 _ftelli64
#else // Other platforms #else // Other platforms
#define FTELL64 ftello #define FTELL64 ftello
@@ -171,7 +171,7 @@ int _fopen(FILE **f, const char *name, const char *mode)
{ {
int ret = 0; int ret = 0;
#ifdef _WIN32 #ifdef _MSC_VER
ret = (int)fopen_s(f, name, mode); ret = (int)fopen_s(f, name, mode);
#else #else
*f = fopen(name, mode); *f = fopen(name, mode);
@@ -185,7 +185,7 @@ int _get_temp_filename(char **tempname)
{ {
int error = 0; int error = 0;
#ifdef _WIN32 #ifdef _MSC_VER
char *name = NULL; char *name = NULL;
// --- use Windows _tempnam function to get a pointer to an // --- use Windows _tempnam function to get a pointer to an

View File

@@ -22,7 +22,7 @@
// F_OFF Must be a 8 byte / 64 bit integer for large file support // F_OFF Must be a 8 byte / 64 bit integer for large file support
#ifdef _WIN32 // Windows (32-bit and 64-bit) #ifdef _MSC_VER // Windows (32-bit and 64-bit)
#define F_OFF __int64 #define F_OFF __int64
#else // Other platforms #else // Other platforms
#define F_OFF off_t #define F_OFF off_t
@@ -44,7 +44,7 @@ file_handle_t *create_file_manager();
void delete_file_manager(file_handle_t *file_handle); void delete_file_manager(file_handle_t *file_handle);
void get_filename(file_handle_t *file_handle, char **filename, size_t *size); int get_filename(file_handle_t *file_handle, char **filename);
int open_file(file_handle_t *file_handle, const char *filename, const char *file_mode); int open_file(file_handle_t *file_handle, const char *filename, const char *file_mode);

View File

@@ -11,6 +11,8 @@
****************************************************************************** ******************************************************************************
*/ */
#include <math.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_toolkit.hpp" #include "test_toolkit.hpp"

View File

@@ -15,10 +15,10 @@ void mock_lookup(int errcode, char *errmsg, int len)
char *msg = NULL; char *msg = NULL;
if (errcode == 100) { if (errcode == 100) {
msg = MESSAGE_STRING; msg = (char *)MESSAGE_STRING;
} }
else { else {
msg = ""; msg = (char *)"";
} }
strncpy(errmsg, msg, len); strncpy(errmsg, msg, len);
} }

View File

@@ -82,11 +82,11 @@ struct Fixture{
BOOST_FIXTURE_TEST_CASE(test_temp_file, Fixture) BOOST_FIXTURE_TEST_CASE(test_temp_file, Fixture)
{ {
char *filename; char *filename;
size_t size;
printf_file(file_handle, "%s", "This is a test."); printf_file(file_handle, "%s", "This is a test.");
get_filename(file_handle, &filename, &size); error = get_filename(file_handle, &filename);
BOOST_REQUIRE(error == 0);
BOOST_CHECK(is_valid(file_handle) == true); BOOST_CHECK(is_valid(file_handle) == true);
BOOST_CHECK(boost::filesystem::exists(filename) == true); BOOST_CHECK(boost::filesystem::exists(filename) == true);