Skip to content

Commit 7bbd858

Browse files
author
Allen Winter
committed
Build the project for MSVC with 'W3 /WX' compile option
MSVC's W3 option displays (production quality) warnings The WX means error if a warning is encountered
1 parent 92ccb22 commit 7bbd858

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,14 @@ if(WIN32)
323323
if(USE_32BIT_TIME_T)
324324
add_definitions(-D_USE_32BIT_TIME_T)
325325
endif()
326+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /WX")
327+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX")
326328
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4211") #allow redefine extern as static
327329
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4290") #C++ exception specification ignored
328330
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4068") #unknown pragma
329331
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4028") #formal parameter differs
330332
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4068") #unknown pragma
333+
331334
endif()
332335
add_definitions(-DBIG_ENDIAN=0 -DLITTLE_ENDIAN=1 -DBYTE_ORDER=BIG_ENDIAN)
333336
endif()

config.h.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,12 @@ typedef unsigned int wint_t;
428428
/* read - system function to read from a file descriptor */
429429
#if defined(HAVE__READ)
430430
#include <io.h>
431+
#if defined(__cplusplus)
431432
#define read _read
432433
#else
434+
#define read(a, b, c) _read((a), (b), (unsigned)(c))
435+
#endif
436+
#else
433437
#if !defined(HAVE_READ)
434438
#error "No read from file descriptor system function available"
435439
#else
@@ -442,8 +446,12 @@ typedef unsigned int wint_t;
442446
/* write - system function to write to a file descriptor */
443447
#if defined(HAVE__WRITE)
444448
#include <io.h>
449+
#if defined(__cplusplus)
445450
#define write _write
446451
#else
452+
#define write(a, b, c) _write((a), (b), (unsigned int)(c))
453+
#endif
454+
#else
447455
#if !defined(HAVE_WRITE)
448456
#error "No write to file descriptor system function available"
449457
#else

src/libical/icalvalue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static int simple_str_to_doublestr(const char *from, char *result, int result_le
375375
++cur;
376376
}
377377
end = cur;
378-
len = end - start;
378+
len = (int)(ptrdiff_t)(end - start);
379379
if (len + 1 >= result_len) {
380380
/* huh hoh, number is too big. truncate it */
381381
len = result_len - 1;

src/libicalvcard/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ target_link_libraries(
179179
icalvcard ical
180180
)
181181

182-
if(MSVC)
183-
target_compile_options(icalvcard PRIVATE /W4 /WX)
184-
else()
185-
target_compile_options(icalvcard PRIVATE -Wall -Wextra -Werror)
186-
endif()
187-
188182
if(MSVC)
189183
set_target_properties(icalvcard PROPERTIES PREFIX "lib")
190184
if(NOT SHARED_ONLY AND NOT STATIC_ONLY)

src/test/vcf_leak.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
4646
}
4747

4848
using vcardptr = std::unique_ptr<VObject, decltype(&cleanVObject)>;
49-
vcardptr ptr(Parse_MIME((char *)content.c_str(), content.size()), cleanVObject);
49+
vcardptr ptr(Parse_MIME((char *)content.c_str(), static_cast<unsigned long>(content.size())), cleanVObject);
5050

5151
return 0;
5252
}

0 commit comments

Comments
 (0)