From c6f27e1e69d5962933113f519d0c11060633459c Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Tue, 4 Apr 2017 18:51:09 -0400 Subject: [PATCH] Platform depedency with fopen --- stable.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/stable.c b/stable.c index a658dc2..d28ced3 100644 --- a/stable.c +++ b/stable.c @@ -292,9 +292,16 @@ int st_store(STD s_table){ FILE *out; /* The target file*/ int i; + /* Windows does not like fopen, and fopen_s is Windows-only. This will ensure the + * use of the proper function call if PLATYPUS is being built on a non-windows system + */ +#ifdef _WIN32 if(fopen_s(&out, ST_FILE_NAME, "w+") != 0) - return -1; /* Can't open file, stop. */ - +#else + if ((out = fopen(ST_FILE_NAME, "w+")) == NULL) +#endif + return -1; /* Can't open file, stop. */ + fprintf(out, "%d", s_table.st_size); for(i = 0; i < s_table.st_size; ++i){