Suppress "may be unsafe" MSVC compiler warnings for C functions (#4789)

* Suppress C function warnings in Windows using pragmas
This commit is contained in:
Paul Johnson
2026-01-05 20:07:35 +00:00
committed by GitHub
parent 3a995f768e
commit d57b7c5ead
17 changed files with 89 additions and 2 deletions

View File

@@ -22,6 +22,11 @@
#include <QDebug>
#include <QTime>
#ifdef Q_CC_MSVC
// 'strcpy': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
static float timeout_blanking=2.0; // time before reporting stale data, seconds
static float timeout_drop=2.0; // time before reporting dropped message
static float timeout_scan=10.0; // time to do initial scan

View File

@@ -26,6 +26,11 @@
// need to get rid of this and use a string...
#include <stdio.h>
#ifdef Q_CC_MSVC
// 'strcpy': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
#ifdef YY_FLEX_SUBMINOR_VERSION
# define YY_FLEX_VERSION \
(YY_FLEX_MAJOR_VERSION) * 1000000 \

View File

@@ -60,6 +60,13 @@
#include <QStyleFactory>
#endif
#ifdef Q_CC_MSVC
// 'freopen': This function or variable may be unsafe.
// 'fileno': The POSIX name for this item is deprecated.
// 'dup2': The POSIX name for this item is deprecated.
#pragma warning(disable:4996)
#endif
//
// bootstrap state
//

View File

@@ -24,6 +24,11 @@
#include <errno.h>
//#include <termios.h>
#ifdef Q_CC_MSVC
// 'sprintf': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
#define JOULE_DEBUG false // debug traces
// Start pattern

View File

@@ -23,6 +23,11 @@
#include <cmath>
#include <errno.h>
#ifdef Q_CC_MSVC
// 'sprintf': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
#define MACRO_DEBUG false
#define UNKNOWN 0x00

View File

@@ -26,6 +26,11 @@
#include <errno.h>
#include <string.h>
#ifdef Q_CC_MSVC
// 'sprintf': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
static bool moxyRegistered =
Devices::addType("Moxy Muscle Oxygen Monitor", DevicesPtr(new MoxyDevices()) );

View File

@@ -21,6 +21,11 @@
#include <cmath>
#include "assert.h"
#ifdef Q_CC_MSVC
// 'sprintf': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
#define PT_DEBUG false
static bool powerTapRegistered =

View File

@@ -30,6 +30,13 @@
#define DUP(fd) dup(fd)
#endif
#ifdef Q_CC_MSVC
// 'fscanf': This function or variable may be unsafe.
// 'sprintf': This function or variable may be unsafe.
// 'fdopen': The POSIX name for this item is deprecated.
#pragma warning(disable:4996)
#endif
static int rawFileReaderRegistered =
RideFileFactory::instance().registerReader(
"raw", "GoldenCheetah Raw PowerTap Format", new RawFileReader());

View File

@@ -43,6 +43,11 @@
#include <unistd.h>
#endif
#ifdef Q_CC_MSVC
// 'strcpy': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
bool SerialRegistered = CommPort::addListFunction(&Serial::myListCommPorts);
#ifdef Q_OS_WIN32

View File

@@ -32,6 +32,13 @@
#include <sys/stat.h>
#include <fcntl.h>
#ifdef Q_CC_MSVC
// '_open': This function or variable may be unsafe.
// 'strcpy': This function or variable may be unsafe.
// 'strerror': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
static int srdFileReaderRegistered =
RideFileFactory::instance().registerReader(
"srd", "Polar SRD files", new SrdFileReader());

View File

@@ -24,6 +24,10 @@
#include <stdint.h>
#include <cmath>
#ifdef Q_CC_MSVC
// 'sprintf': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
static int syncFileReaderRegistered =
RideFileFactory::instance().registerReader(

View File

@@ -26,6 +26,13 @@
#include <algorithm> // for std::sort
#include "cmath"
#ifdef Q_CC_MSVC
// 'sprintf': This function or variable may be unsafe.
// 'strcpy': This function or variable may be unsafe.
// 'strncpy': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
static int wkoFileReaderRegistered = RideFileFactory::instance().registerReader(
"wko", "WKO+ Files", new WkoFileReader());

View File

@@ -31,6 +31,11 @@
#include <errno.h>
#include <QtGui>
#ifdef Q_CC_MSVC
// 'strerror': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
DownloadRideDialog::DownloadRideDialog(Context *context, bool embedded) :
context(context), cancelled(false),
action(actionIdle), embedded(embedded)

View File

@@ -27,6 +27,11 @@
#include "RealtimeController.h" // for power trainer definitions
#include "MultiRegressionizer.h"
#ifdef Q_CC_MSVC
// 'strcpy': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
// WIZARD FLOW
//
// 10. Select Device Type

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2019 Eric Christoffersen (impolexg@outlook.com)
*
* This program is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@ const PolyFit<double>* GetAltitudeFit(unsigned maxOrder) {
#if 1
// Data from : Prediction of Critical Powerand W? in Hypoxia : Application to Work - Balance Modelling
// by Nathan E.Townsend1, David S.Nichols, Philip F.Skiba, Sebastien Racinais and Julien D.Périard
// by Nathan E.Townsend1, David S.Nichols, Philip F.Skiba, Sebastien Racinais and Julien D.Périard
//
// Data in paper doesn't exceed 4250m. Cubic equation in paper decreases slope after 5000m, which doesn't
// make sense, so using best fit 3rd order rational instead. Our equation continues at constant slope from

View File

@@ -21,6 +21,11 @@
#include "RealtimeData.h"
#include "Units.h"
#ifdef Q_CC_MSVC
// 'strcpy': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
void VirtualPowerTrainer::to_string(std::string& s) const {
// poly|wheelrpm|name
s.clear();

View File

@@ -22,6 +22,11 @@
#include <QtDebug>
#ifdef Q_CC_MSVC
// 'strcpy': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
RealtimeData::RealtimeData()
{
name[0] = '\0';