Fix compile with MSVC
This commit is contained in:
parent
55e038d345
commit
d02241d32c
@ -35,7 +35,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
list(APPEND COMPILE_OPTIONS
|
if(MSVC)
|
||||||
|
list(APPEND COMPILE_OPTIONS /std:c++17 /MP)
|
||||||
|
else()
|
||||||
|
list(APPEND COMPILE_OPTIONS
|
||||||
$<$<COMPILE_LANGUAGE:C>:-std=c99>
|
$<$<COMPILE_LANGUAGE:C>:-std=c99>
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
|
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
|
||||||
-Wall
|
-Wall
|
||||||
@ -57,7 +60,8 @@ list(APPEND COMPILE_OPTIONS
|
|||||||
$<$<COMPILE_LANGUAGE:CXX>:-Woverloaded-virtual>
|
$<$<COMPILE_LANGUAGE:CXX>:-Woverloaded-virtual>
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-Wno-old-style-cast>
|
$<$<COMPILE_LANGUAGE:CXX>:-Wno-old-style-cast>
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-fpermissive>
|
$<$<COMPILE_LANGUAGE:CXX>:-fpermissive>
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
option(BUILD_WERROR "Build with -Werror" OFF)
|
option(BUILD_WERROR "Build with -Werror" OFF)
|
||||||
if(BUILD_WERROR)
|
if(BUILD_WERROR)
|
||||||
@ -307,7 +311,7 @@ if(NOT SPARKLE AND (APPLE OR WIN32))
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32 AND NOT MSVC)
|
||||||
# RC compiler
|
# RC compiler
|
||||||
string(REPLACE "gcc" "windres" CMAKE_RC_COMPILER_INIT ${CMAKE_C_COMPILER})
|
string(REPLACE "gcc" "windres" CMAKE_RC_COMPILER_INIT ${CMAKE_C_COMPILER})
|
||||||
enable_language(RC)
|
enable_language(RC)
|
||||||
@ -487,6 +491,9 @@ add_definitions(-DQT_NO_CAST_TO_ASCII)
|
|||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_definitions(-DUNICODE)
|
add_definitions(-DUNICODE)
|
||||||
|
if(MSVC)
|
||||||
|
add_definitions(-DPROTOBUF_USE_DLLS)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Subdirectories
|
# Subdirectories
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cxxabi.h>
|
#ifndef _MSC_VER
|
||||||
|
# include <cxxabi.h>
|
||||||
|
#endif
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#ifdef HAVE_BACKTRACE
|
#ifdef HAVE_BACKTRACE
|
||||||
@ -275,8 +277,8 @@ static T CreateLogger(Level level, const QString &class_name, int line, const ch
|
|||||||
return ret.space();
|
return ret.space();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
QString CXXDemangle(const QString &mangled_function);
|
QString CXXDemangle(const QString &mangled_function);
|
||||||
|
|
||||||
QString CXXDemangle(const QString &mangled_function) {
|
QString CXXDemangle(const QString &mangled_function) {
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
@ -289,9 +291,24 @@ QString CXXDemangle(const QString &mangled_function) {
|
|||||||
return mangled_function; // Probably not a C++ function.
|
return mangled_function; // Probably not a C++ function.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif // Q_OS_UNIX
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
QString LinuxDemangle(const QString &symbol);
|
||||||
|
QString LinuxDemangle(const QString &symbol) {
|
||||||
|
|
||||||
|
QRegularExpression regex("\\(([^+]+)");
|
||||||
|
QRegularExpressionMatch match = regex.match(symbol);
|
||||||
|
if (!match.hasMatch()) {
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
QString mangled_function = match.captured(1);
|
||||||
|
return CXXDemangle(mangled_function);
|
||||||
|
}
|
||||||
|
#endif // Q_OS_LINUX
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
QString DarwinDemangle(const QString &symbol);
|
QString DarwinDemangle(const QString &symbol);
|
||||||
|
|
||||||
QString DarwinDemangle(const QString &symbol) {
|
QString DarwinDemangle(const QString &symbol) {
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
@ -303,23 +320,9 @@ QString DarwinDemangle(const QString &symbol) {
|
|||||||
return CXXDemangle(mangled_function);
|
return CXXDemangle(mangled_function);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif // Q_OS_MACOS
|
||||||
QString LinuxDemangle(const QString &symbol);
|
|
||||||
|
|
||||||
QString LinuxDemangle(const QString &symbol) {
|
|
||||||
|
|
||||||
QRegularExpression regex("\\(([^+]+)");
|
|
||||||
QRegularExpressionMatch match = regex.match(symbol);
|
|
||||||
if (!match.hasMatch()) {
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
QString mangled_function = match.captured(1);
|
|
||||||
return CXXDemangle(mangled_function);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DemangleSymbol(const QString &symbol);
|
QString DemangleSymbol(const QString &symbol);
|
||||||
|
|
||||||
QString DemangleSymbol(const QString &symbol) {
|
QString DemangleSymbol(const QString &symbol) {
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
return DarwinDemangle(symbol);
|
return DarwinDemangle(symbol);
|
||||||
|
@ -29,12 +29,20 @@
|
|||||||
# define qLog(level) while (false) QNoDebug()
|
# define qLog(level) while (false) QNoDebug()
|
||||||
# define qLogCat(level, category) while (false) QNoDebug()
|
# define qLogCat(level, category) while (false) QNoDebug()
|
||||||
#else
|
#else
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# define qLog(level) logging::CreateLogger##level(__LINE__, __FUNCSIG__, nullptr)
|
||||||
|
# else
|
||||||
# define qLog(level) logging::CreateLogger##level(__LINE__, __PRETTY_FUNCTION__, nullptr)
|
# define qLog(level) logging::CreateLogger##level(__LINE__, __PRETTY_FUNCTION__, nullptr)
|
||||||
|
# endif // _MSC_VER
|
||||||
|
|
||||||
// This macro specifies a separate category for message filtering.
|
// This macro specifies a separate category for message filtering.
|
||||||
// The default qLog will use the class name extracted from the function name for this purpose.
|
// The default qLog will use the class name extracted from the function name for this purpose.
|
||||||
// The category is also printed in the message along with the class name.
|
// The category is also printed in the message along with the class name.
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# define qLogCat(level, category) logging::CreateLogger##level(__LINE__, __FUNCSIG__, category)
|
||||||
|
# else
|
||||||
# define qLogCat(level, category) logging::CreateLogger##level(__LINE__, __PRETTY_FUNCTION__, category)
|
# define qLogCat(level, category) logging::CreateLogger##level(__LINE__, __PRETTY_FUNCTION__, category)
|
||||||
|
# endif // _MSC_VER
|
||||||
|
|
||||||
#endif // QT_NO_DEBUG_STREAM
|
#endif // QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
|
@ -18,10 +18,13 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -1179,6 +1179,9 @@ endif()
|
|||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(strawberry_lib PRIVATE dsound dwmapi)
|
target_link_libraries(strawberry_lib PRIVATE dsound dwmapi)
|
||||||
|
if(MSVC)
|
||||||
|
target_link_libraries(strawberry_lib PRIVATE sqlite3)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QtMath>
|
||||||
|
|
||||||
FHT::FHT(int n) : num_((n < 3) ? 0 : 1 << n), exp2_((n < 3) ? -1 : n) {
|
FHT::FHT(int n) : num_((n < 3) ? 0 : 1 << n), exp2_((n < 3) ? -1 : n) {
|
||||||
|
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <getopt.h>
|
#ifndef _MSC_VER
|
||||||
|
# include <getopt.h>
|
||||||
|
#endif
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@ -119,6 +121,7 @@ void CommandlineOptions::RemoveArg(const QString &starts_with, int count) {
|
|||||||
|
|
||||||
bool CommandlineOptions::Parse() {
|
bool CommandlineOptions::Parse() {
|
||||||
|
|
||||||
|
#ifndef _MSC_VER // TODO: Consider QCommandLineOption.
|
||||||
static const struct option kOptions[] = {
|
static const struct option kOptions[] = {
|
||||||
{"help", no_argument, nullptr, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{"play", no_argument, nullptr, 'p'},
|
{"play", no_argument, nullptr, 'p'},
|
||||||
@ -319,6 +322,8 @@ bool CommandlineOptions::Parse() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -613,8 +613,8 @@ void SongLoader::ErrorMessageReceived(GstMessage *msg) {
|
|||||||
gchar *debugs = nullptr;
|
gchar *debugs = nullptr;
|
||||||
|
|
||||||
gst_message_parse_error(msg, &error, &debugs);
|
gst_message_parse_error(msg, &error, &debugs);
|
||||||
qLog(Error) << __PRETTY_FUNCTION__ << error->message;
|
qLog(Error) << error->message;
|
||||||
qLog(Error) << __PRETTY_FUNCTION__ << debugs;
|
qLog(Error) << debugs;
|
||||||
|
|
||||||
QString message_str = error->message;
|
QString message_str = error->message;
|
||||||
|
|
||||||
|
@ -697,7 +697,7 @@ QString GetEnv(const QString &key) {
|
|||||||
void SetEnv(const char *key, const QString &value) {
|
void SetEnv(const char *key, const QString &value) {
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
putenv(QString("%1=%2").arg(key, value).toLocal8Bit().constData());
|
_putenv(QString("%1=%2").arg(key, value).toLocal8Bit().constData());
|
||||||
#else
|
#else
|
||||||
setenv(key, value.toLocal8Bit().constData(), 1);
|
setenv(key, value.toLocal8Bit().constData(), 1);
|
||||||
#endif
|
#endif
|
||||||
@ -785,7 +785,19 @@ QString DesktopEnvironment() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UnicodeToAscii(const QString &unicode) {
|
QString UnicodeToAscii(QString unicode) {
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
return unicode
|
||||||
|
.replace(QChar(229), "a")
|
||||||
|
.replace(QChar(197), 'A')
|
||||||
|
.replace(QChar(230), "ae")
|
||||||
|
.replace(QChar(198), "AE")
|
||||||
|
.replace(QChar(248), 'o')
|
||||||
|
.replace(QChar(216), 'O');
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#ifdef LC_ALL
|
#ifdef LC_ALL
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
@ -816,6 +828,8 @@ QString UnicodeToAscii(const QString &unicode) {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MacAddress() {
|
QString MacAddress() {
|
||||||
|
@ -132,7 +132,7 @@ QString GetRandomString(const int len, const QString &UseCharacters);
|
|||||||
|
|
||||||
QString DesktopEnvironment();
|
QString DesktopEnvironment();
|
||||||
|
|
||||||
QString UnicodeToAscii(const QString &unicode);
|
QString UnicodeToAscii(QString unicode);
|
||||||
|
|
||||||
QString MacAddress();
|
QString MacAddress();
|
||||||
|
|
||||||
|
@ -40,10 +40,12 @@ class DirectSoundDeviceFinder : public DeviceFinder {
|
|||||||
QList<Device> devices;
|
QList<Device> devices;
|
||||||
};
|
};
|
||||||
|
|
||||||
static BOOL EnumerateCallback(LPGUID guid,
|
static BOOL EnumerateCallback(LPGUID guid, LPCSTR description, LPCSTR module, LPVOID state_voidptr)
|
||||||
LPCSTR description,
|
#ifdef _MSC_VER
|
||||||
LPCSTR module,
|
;
|
||||||
LPVOID state_voidptr) __attribute__((stdcall));
|
#else
|
||||||
|
__attribute__((stdcall));
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIRECTSOUNDDEVICEFINDER_H
|
#endif // DIRECTSOUNDDEVICEFINDER_H
|
||||||
|
@ -875,7 +875,7 @@ void GstEngine::UpdateScope(const int chunk_length) {
|
|||||||
sample_type *dest = scope_.data();
|
sample_type *dest = scope_.data();
|
||||||
source += (chunk_size / sizeof(sample_type)) * scope_chunk_;
|
source += (chunk_size / sizeof(sample_type)) * scope_chunk_;
|
||||||
|
|
||||||
int bytes = 0;
|
size_t bytes = 0;
|
||||||
|
|
||||||
// Make sure we don't go beyond the end of the buffer
|
// Make sure we don't go beyond the end of the buffer
|
||||||
if (scope_chunk_ == scope_chunks_ - 1) {
|
if (scope_chunk_ == scope_chunks_ - 1) {
|
||||||
|
@ -22,7 +22,11 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <initguid.h>
|
#include <initguid.h>
|
||||||
#include <devpkey.h>
|
#include <devpkey.h>
|
||||||
#include <functiondiscoverykeys_devpkey.h>
|
#ifdef _MSC_VER
|
||||||
|
# include <functiondiscoverykeys.h>
|
||||||
|
#else
|
||||||
|
# include <functiondiscoverykeys_devpkey.h>
|
||||||
|
#endif
|
||||||
#include <mmdeviceapi.h>
|
#include <mmdeviceapi.h>
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@ -32,6 +36,11 @@
|
|||||||
#include "mmdevicefinder.h"
|
#include "mmdevicefinder.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
DEFINE_GUID(IID_IMMDeviceEnumerator, 0xa95664d2, 0x9614, 0x4f35, 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6);
|
||||||
|
DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xbcde0395, 0xe52f, 0x467c, 0x8e, 0x3d, 0xc4, 0x57, 0x92, 0x91, 0x69, 0x2e);
|
||||||
|
#endif
|
||||||
|
|
||||||
MMDeviceFinder::MMDeviceFinder() : DeviceFinder("mmdevice", { "wasapisink" }) {}
|
MMDeviceFinder::MMDeviceFinder() : DeviceFinder("mmdevice", { "wasapisink" }) {}
|
||||||
|
|
||||||
QList<DeviceFinder::Device> MMDeviceFinder::ListDevices() {
|
QList<DeviceFinder::Device> MMDeviceFinder::ListDevices() {
|
||||||
|
@ -2164,13 +2164,13 @@ void Playlist::RemoveDeletedSongs() {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct SongSimilarHash {
|
struct SongSimilarHash {
|
||||||
long operator() (const Song &song) const {
|
size_t operator() (const Song &song) const {
|
||||||
return HashSimilar(song);
|
return HashSimilar(song);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SongSimilarEqual {
|
struct SongSimilarEqual {
|
||||||
long operator()(const Song &song1, const Song &song2) const {
|
size_t operator()(const Song &song1, const Song &song2) const {
|
||||||
return song1.IsSimilar(song2);
|
return song1.IsSimilar(song2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user