Compiler warnings un MS Visual Studio 32 & 64-bit builds
I am building libqrencode.lib as a static library for use in an Open Source project using Microsoft's Visual Studio 2015 & 2017. Visual Studio generates the following warnings:
32-bit build
qrinput.c(1594): warning C4244: 'function': conversion from 'int' to 'unsigned char', possible loss of data
rscode.c(151): warning C4244: '=': conversion from 'int' to 'data_t', possible loss of data
rscode.c(155): warning C4244: '=': conversion from 'int' to 'data_t', possible loss of data
rscode.c(156): warning C4244: '=': conversion from 'int' to 'data_t', possible loss of data
rsecc.c(66): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
rsecc.c(67): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
split.c(282): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup.
64-bit build
qrencode.c(678): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
qrencode.c(692): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
qrencode.c(850): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
qrencode.c(859): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
qrinput.c(1594): warning C4244: 'function': conversion from 'int' to 'unsigned char', possible loss of data
rscode.c(151): warning C4244: '=': conversion from 'int' to 'data_t', possible loss of data
rscode.c(155): warning C4244: '=': conversion from 'int' to 'data_t', possible loss of data
rscode.c(156): warning C4244: '=': conversion from 'int' to 'data_t', possible loss of data
rsecc.c(66): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
rsecc.c(67): warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
split.c(96): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
split.c(139): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(140): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(142): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(152): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
split.c(179): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
split.c(216): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(217): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(219): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(234): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(235): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(237): warning C4244: 'function': conversion from '__int64' to 'int', possible loss of data
split.c(247): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
split.c(282): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup.
I use the following manual "config.h" file and use the Preprocessor variable definition HAVE_CONFIG_H:
#ifndef CONFIG_H
#define CONFIG_H
// manual config.h for Microsoft Visual Studio
#define HAVE_INTTYPES_H 1
#define HAVE_MEMORY_H 1
#define HAVE_SDL 0
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRDUP 1
#define HAVE_STRING_H 1
#define HAVE_SYS_STAT_H 1
#define STATIC_IN_RELEASE
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define MAJOR_VERSION 3
#define MINOR_VERSION 9
#define MICRO_VERSION 0
#define VERSION "3.9.0"
#endif
I could suppress the strdup depreciated messages (C4996) using :
#define _CRT_NONSTDC_NO_DEPRECATE 1
but I think they shouldn't happen rather than be suppressed.
Many thanks
Hi @c-273 ,
Thank you for your suggestion. Next major release will use size_t widely. _stricmp and _strncmp macros seem good. I'll use them.
This is little bit ugly, but how is this patch?
diff --git a/qrenc.c b/qrenc.c
index dce4500..c7cbaf8 100644
--- a/qrenc.c
+++ b/qrenc.c
@@ -30,6 +30,11 @@
#include "qrencode.h"
+#ifdef _MSC_VER
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#endif
+
#define INCHES_PER_METER (100.0/2.54)
static int casesensitive = 1;
Hi,
This is Claire his daughter. My dad passed away last week and so won't be replying anymore. Good luck
On 2 September 2017 at 06:22, Kentaro Fukuchi [email protected] wrote:
This is little bit ugly, but how is this patch?
diff --git a/qrenc.c b/qrenc.c index dce4500..c7cbaf8 100644 --- a/qrenc.c +++ b/qrenc.c @@ -30,6 +30,11 @@
#include "qrencode.h"
+#ifdef _MSC_VER +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#endif + #define INCHES_PER_METER (100.0/2.54)
static int casesensitive = 1;
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fukuchi/libqrencode/issues/102#issuecomment-326723048, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkMQMZhT7D_9jpOF9GPkmHSUVr6sliHks5seOYogaJpZM4PChcq .
Oh, I'm sorry. I'd like to thank him for his contribution.
Thank you please let the others know.
On 8 September 2017 at 14:08, Kentaro Fukuchi [email protected] wrote:
Oh, I'm sorry. I'd like to thank him for his contribution.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fukuchi/libqrencode/issues/102#issuecomment-328098441, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkMQDqL_Khnk2o1g-le-5mWr1lWhvbxks5sgTwzgaJpZM4PChcq .