Skip to content

Compiler warnings un MS Visual Studio 32 & 64-bit builds #102

@c-273

Description

@c-273

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions