From 743d439641cea930bafe643ac4e82704bfb59175 Mon Sep 17 00:00:00 2001 From: Dmitry Mikushin Date: Sun, 26 May 2024 18:33:53 +0200 Subject: [PATCH] Support specification of additional user defines, e.g. those that may come from the compiler command line options --- source/tcppLibrary.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/tcppLibrary.hpp b/source/tcppLibrary.hpp index d1170e3..46a8057 100644 --- a/source/tcppLibrary.hpp +++ b/source/tcppLibrary.hpp @@ -337,7 +337,7 @@ namespace tcpp public: Preprocessor() TCPP_NOEXCEPT = delete; Preprocessor(const Preprocessor&) TCPP_NOEXCEPT = delete; - Preprocessor(Lexer& lexer, const TPreprocessorConfigInfo& config) TCPP_NOEXCEPT; + Preprocessor(Lexer& lexer, const TPreprocessorConfigInfo& config, TSymTable userDefines = {}) TCPP_NOEXCEPT; ~Preprocessor() TCPP_NOEXCEPT = default; bool AddCustomDirectiveHandler(const std::string& directive, const TDirectiveHandler& handler) TCPP_NOEXCEPT; @@ -1078,13 +1078,18 @@ namespace tcpp }; - Preprocessor::Preprocessor(Lexer& lexer, const TPreprocessorConfigInfo& config) TCPP_NOEXCEPT: + Preprocessor::Preprocessor(Lexer& lexer, const TPreprocessorConfigInfo& config, TSymTable userDefines) TCPP_NOEXCEPT: mpLexer(&lexer), mOnErrorCallback(config.mOnErrorCallback), mOnIncludeCallback(config.mOnIncludeCallback), mSkipCommentsTokens(config.mSkipComments) { for (auto&& currSystemDefine : BuiltInDefines) { mSymTable.push_back({ currSystemDefine }); } + + for (auto&& currUserDefine : userDefines) + { + mSymTable.push_back(currUserDefine); + } } bool Preprocessor::AddCustomDirectiveHandler(const std::string& directive, const TDirectiveHandler& handler) TCPP_NOEXCEPT @@ -1984,4 +1989,4 @@ namespace tcpp } #endif -} \ No newline at end of file +}