fix #327 - enhancement: Auto define macro "_DEBUG" for "Debug" compiler set(like visual studio).

This commit is contained in:
Roy Qu 2024-03-26 12:54:25 +08:00
parent a24debae6f
commit 76e098bfc6
5 changed files with 19 additions and 4 deletions

View File

@ -88,6 +88,8 @@ Red Panda C++ Version 2.27
- change: Set focus to "find" button when "find in files..." dialog is openned. - change: Set focus to "find" button when "find in files..." dialog is openned.
- enhancement: Correct tab orders for all setting pages/dialogs. - enhancement: Correct tab orders for all setting pages/dialogs.
- enhancement: Shortcut key for buttons in find/replace and "find in files" dialogs. - enhancement: Shortcut key for buttons in find/replace and "find in files" dialogs.
- enhancement: Auto define macro "_DEBUG" for "Debug" compiler set(like visual studio).
Red Panda C++ Version 2.26 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

@ -138,7 +138,9 @@ bool FileCompiler::prepareForCompile()
default: default:
throw CompileError(tr("Can't find the compiler for file %1").arg(mFilename)); throw CompileError(tr("Can't find the compiler for file %1").arg(mFilename));
} }
if (mArguments.contains("-g3")) {
mArguments << "-D_DEBUG";
}
if (!mOnlyCheckSyntax) if (!mOnlyCheckSyntax)
mArguments += getLibraryArguments(fileType); mArguments += getLibraryArguments(fileType);

View File

@ -226,8 +226,10 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
QStringList cCompileArguments = getCCompileArguments(false); QStringList cCompileArguments = getCCompileArguments(false);
QStringList cxxCompileArguments = getCppCompileArguments(false); QStringList cxxCompileArguments = getCppCompileArguments(false);
if (cCompileArguments.contains("-g3")) { if (cCompileArguments.contains("-g3")) {
cCompileArguments << "-D__DEBUG__"; cCompileArguments << "-D_DEBUG";
cxxCompileArguments << "-D__DEBUG__"; }
if (cxxCompileArguments.contains("-g3")) {
cxxCompileArguments << "-D_DEBUG";
} }
QStringList libraryArguments = getLibraryArguments(FileType::Project); QStringList libraryArguments = getLibraryArguments(FileType::Project);
QStringList cIncludeArguments = getCIncludeArguments(); QStringList cIncludeArguments = getCIncludeArguments();

View File

@ -143,7 +143,8 @@ void SDCCProjectCompiler::writeMakeDefines(QFile &file)
QStringList cCompileArguments = getCCompileArguments(mOnlyCheckSyntax); QStringList cCompileArguments = getCCompileArguments(mOnlyCheckSyntax);
if (cCompileArguments.contains("-g3")) if (cCompileArguments.contains("-g3"))
cCompileArguments << "-D__DEBUG__"; cCompileArguments << "-D_DEBUG";
QStringList libraryArguments = getLibraryArguments(FileType::Project); QStringList libraryArguments = getLibraryArguments(FileType::Project);
QStringList cIncludeArguments = getCIncludeArguments() + getProjectIncludeArguments(); QStringList cIncludeArguments = getCIncludeArguments() + getProjectIncludeArguments();

View File

@ -2510,6 +2510,10 @@ QStringList Settings::CompilerSet::defines(bool isCpp) {
if (!mCompileOptions[key].isEmpty()) if (!mCompileOptions[key].isEmpty())
arguments.append(pOption->setting + mCompileOptions[key]); arguments.append(pOption->setting + mCompileOptions[key]);
} }
pOption = CompilerInfoManager::getCompilerOption(compilerType(), CC_CMD_OPT_DEBUG_INFO);
if (pOption && mCompileOptions.contains(CC_CMD_OPT_DEBUG_INFO)) {
arguments.append(pOption->setting);
}
#ifdef ENABLE_SDCC #ifdef ENABLE_SDCC
} }
#endif #endif
@ -2518,8 +2522,12 @@ QStringList Settings::CompilerSet::defines(bool isCpp) {
QStringList extraParams = parseArgumentsWithoutVariables(mCustomCompileParams); QStringList extraParams = parseArgumentsWithoutVariables(mCustomCompileParams);
arguments.append(extraParams); arguments.append(extraParams);
} }
if (arguments.contains("-g3"))
arguments.append("-D_DEBUG");
arguments.append(NULL_FILE); arguments.append(NULL_FILE);
qDebug()<<arguments;
QFileInfo ccompiler(mCCompiler); QFileInfo ccompiler(mCCompiler);
QByteArray output = getCompilerOutput(ccompiler.absolutePath(),ccompiler.fileName(),arguments); QByteArray output = getCompilerOutput(ccompiler.absolutePath(),ccompiler.fileName(),arguments);
// 'cpp.exe -dM -E -x c++ -std=c++17 NUL' // 'cpp.exe -dM -E -x c++ -std=c++17 NUL'