diff --git a/NEWS.md b/NEWS.md index a93ec0fb..49c8cab3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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; diff --git a/RedPandaIDE/compiler/compiler.cpp b/RedPandaIDE/compiler/compiler.cpp index 0082d35a..0f2c9f27 100644 --- a/RedPandaIDE/compiler/compiler.cpp +++ b/RedPandaIDE/compiler/compiler.cpp @@ -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) { diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index f910f363..d6530295 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -8,6 +8,7 @@ #include "../settings.h" #include #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.") + +"
" + +tr("Strings in the program might be wrongly processed.")); + } { QMutexLocker locker(&mCompileMutex); if (mCompiler!=nullptr) { diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 99a1435b..9f6545e9 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -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());