- 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
- add: about dialog
- 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
- enhancement: support C++ using type alias;

View File

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

View File

@ -8,6 +8,7 @@
#include "../settings.h"
#include <QMessageBox>
#include "projectcompiler.h"
#include "../platform.h"
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."));
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);
if (mCompiler!=nullptr) {

View File

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