- enhancement: don't add encoding options when using clang to compile (clang only support utf-8)

This commit is contained in:
royqh1979@gmail.com 2021-10-04 00:18:16 +08:00
parent bed1dab265
commit 1c745871b2
4 changed files with 18 additions and 1 deletions

View File

@ -7,6 +7,7 @@ Version 0.6.0
- enhancement: todo view - enhancement: todo view
- add: about dialog - add: about dialog
- implement: correctly recognize clang (msys2 build) - implement: correctly recognize clang (msys2 build)
- enhancement: don't add encoding options when using clang to compile (clang only support utf-8)
Version 0.5.0 Version 0.5.0
- enhancement: support C++ using type alias; - enhancement: support C++ using type alias;

View File

@ -258,7 +258,8 @@ void Compiler::stopCompile()
QString Compiler::getCharsetArgument(const QByteArray& encoding) QString Compiler::getCharsetArgument(const QByteArray& encoding)
{ {
QString result; QString result;
if (compilerSet()->autoAddCharsetParams() && encoding != ENCODING_ASCII) { if (compilerSet()->autoAddCharsetParams() && encoding != ENCODING_ASCII
&& compilerSet()->compilerType()!="Clang") {
QString encodingName; QString encodingName;
QString systemEncodingName=pCharsetInfoManager->getDefaultSystemEncoding(); QString systemEncodingName=pCharsetInfoManager->getDefaultSystemEncoding();
if (encoding == ENCODING_SYSTEM_DEFAULT) { if (encoding == ENCODING_SYSTEM_DEFAULT) {

View File

@ -8,6 +8,7 @@
#include "../settings.h" #include "../settings.h"
#include <QMessageBox> #include <QMessageBox>
#include "projectcompiler.h" #include "projectcompiler.h"
#include "../platform.h"
CompilerManager::CompilerManager(QObject *parent) : QObject(parent) CompilerManager::CompilerManager(QObject *parent) : QObject(parent)
{ {
@ -44,6 +45,18 @@ void CompilerManager::compile(const QString& filename, const QByteArray& encodin
tr("No compiler set is configured.")+tr("Can't start debugging.")); tr("No compiler set is configured.")+tr("Can't start debugging."));
return; return;
} }
if (pSettings->compilerSets().defaultSet()->compilerType() == "Clang"
&& (
(encoding!= ENCODING_ASCII && encoding!=ENCODING_UTF8)
|| (encoding == ENCODING_UTF8
&& pCharsetInfoManager->getDefaultSystemEncoding()!=ENCODING_UTF8)
)) {
QMessageBox::information(pMainWindow,
tr("Encoding not support"),
tr("Clang only support utf-8 encoding.")
+"<br />"
+tr("Strings in the program might be wrongly processed."));
}
{ {
QMutexLocker locker(&mCompileMutex); QMutexLocker locker(&mCompileMutex);
if (mCompiler!=nullptr) { if (mCompiler!=nullptr) {

View File

@ -2481,6 +2481,7 @@ void Settings::CompilerSets::saveSet(int index)
mSettings->mSettings.setValue("Type", pSet->type()); mSettings->mSettings.setValue("Type", pSet->type());
mSettings->mSettings.setValue("Name", pSet->name()); mSettings->mSettings.setValue("Name", pSet->name());
mSettings->mSettings.setValue("Target", pSet->target()); mSettings->mSettings.setValue("Target", pSet->target());
mSettings->mSettings.setValue("CompilerType", pSet->compilerType());
// Paths // Paths
savePathList("Bins",pSet->binDirs()); savePathList("Bins",pSet->binDirs());
@ -2542,6 +2543,7 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
pSet->setType(mSettings->mSettings.value("Type").toString()); pSet->setType(mSettings->mSettings.value("Type").toString());
pSet->setName(mSettings->mSettings.value("Name").toString()); pSet->setName(mSettings->mSettings.value("Name").toString());
pSet->setTarget(mSettings->mSettings.value("Target").toString()); pSet->setTarget(mSettings->mSettings.value("Target").toString());
pSet->setCompilerType(mSettings->mSettings.value("CompilerType").toString());
// Paths // Paths
loadPathList("Bins",pSet->binDirs()); loadPathList("Bins",pSet->binDirs());