sincerely
Singaporean
If you have not done so, read this full tutorial on how to use SGEXTN to build an application.
See here for the previous part of the tutorial.
In the previous part, we completed all the options page code and wrote the background for the display page.
Having completed the options page is a major achievement, so now we can publish our code on GitHub again by committing it to Git and pushing.
Before that, we should first run a clang-tidy check to make sure that the code is of good quality.
If you have not done so, first configure your clang-tidy. Go to Edit › Preferences... › Analyzer › Clang Tools › Run Options, and click the box beside "Diagnostic Configurations". Then in the pop up window, go to Clang-Tidy Checks › Edit checks as string, delete everything in the textbox and copy the configurations below.
-*,bugprone-argument-comment,bugprone-assert-side-effect,bugprone-assignment-in-if-condition,bugprone-bad-signal-to-kill-thread,bugprone-bitwise-pointer-cast,bugprone-bool-pointer-implicit-conversion,bugprone-branch-clone,bugprone-casting-through-void,bugprone-chained-comparison,bugprone-compare-pointer-to-member-virtual-function,bugprone-copy-constructor-init,bugprone-crtp-constructor-accessibility,bugprone-dangling-handle,bugprone-dynamic-static-initializers,bugprone-empty-catch,bugprone-exception-escape,bugprone-fold-init-type,bugprone-forward-declaration-namespace,bugprone-forwarding-reference-overload,bugprone-implicit-widening-of-multiplication-result,bugprone-inaccurate-erase,bugprone-inc-dec-in-conditions,bugprone-incorrect-*,bugprone-infinite-loop,bugprone-integer-division,bugprone-lambda-function-name,bugprone-macro-*,bugprone-misplaced-*,bugprone-move-forwarding-reference,bugprone-multi-level-implicit-pointer-conversion,bugprone-multiple-*,bugprone-narrowing-conversions,bugprone-no-escape,bugprone-non-zero-enum-to-bool-conversion,bugprone-nondeterministic-pointer-iteration-order,bugprone-not-null-terminated-result,bugprone-optional-value-conversion,bugprone-parent-virtual-call,bugprone-pointer-arithmetic-on-polymorphic-object,bugprone-posix-return,bugprone-redundant-branch-condition,bugprone-reserved-identifier,bugprone-return-const-ref-from-parameter,bugprone-shared-ptr-array-mismatch,bugprone-signal-handler,bugprone-signed-char-misuse,bugprone-sizeof-*,bugprone-spuriously-wake-up-functions,bugprone-standalone-empty,bugprone-string-*,bugprone-stringview-nullptr,bugprone-suspicious-*,bugprone-swapped-arguments,bugprone-switch-missing-default-case,bugprone-tagged-union-member-count,bugprone-terminating-continue,bugprone-throw-keyword-missing,bugprone-too-small-loop-variable,bugprone-unchecked-optional-access,bugprone-undefined-memory-manipulation,bugprone-undelegated-constructor,bugprone-unhandled-*,bugprone-unique-ptr-array-mismatch,bugprone-unsafe-functions,bugprone-unused-*,bugprone-use-after-move,bugprone-virtual-near-miss,clang-*,concurrency-*,cppcoreguidelines-avoid-c-arrays,cppcoreguidelines-avoid-capturing-lambda-coroutines,cppcoreguidelines-avoid-const-or-ref-data-members,cppcoreguidelines-avoid-do-while,cppcoreguidelines-avoid-goto,cppcoreguidelines-avoid-reference-coroutine-parameters,cppcoreguidelines-c-copy-assignment-signature,cppcoreguidelines-explicit-virtual-functions,cppcoreguidelines-init-variables,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-macro-*,cppcoreguidelines-misleading-capture-default-by-value,cppcoreguidelines-missing-std-forward,cppcoreguidelines-narrowing-conversions,cppcoreguidelines-no-*,cppcoreguidelines-noexcept-*,cppcoreguidelines-pro-bounds-*,cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-pro-type-cstyle-cast,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-pro-type-union-access,cppcoreguidelines-pro-type-vararg,cppcoreguidelines-rvalue-reference-param-not-moved,cppcoreguidelines-slicing,cppcoreguidelines-special-member-functions,cppcoreguidelines-use-default-member-init,cppcoreguidelines-virtual-class-destructor,misc-confusable-identifiers,misc-const-correctness,misc-coroutine-hostile-raii,misc-definitions-in-headers,misc-header-include-cycle,misc-include-cleaner,misc-misleading-*,misc-misplaced-const,misc-new-delete-overloads,misc-no-recursion,misc-non-copyable-objects,misc-redundant-expression,misc-static-assert,misc-throw-by-value-catch-by-reference,misc-unconventional-assign-operator,misc-uniqueptr-reset-release,misc-unused-*,misc-use-*,modernize-avoid-*,modernize-concat-nested-namespaces,modernize-deprecated-*,modernize-macro-to-enum,modernize-make-*,modernize-min-max-use-initializer-list,modernize-pass-by-value,modernize-redundant-void-arg,modernize-replace-*,modernize-shrink-to-fit,modernize-type-traits,modernize-unary-static-assert,modernize-use-bool-literals,modernize-use-constraints,modernize-use-default-member-init,modernize-use-designated-initializers,modernize-use-emplace,modernize-use-equals-*,modernize-use-nodiscard,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-ranges,modernize-use-starts-ends-with,modernize-use-std-*,modernize-use-transparent-functors,modernize-use-uncaught-exceptions,modernize-use-using,performance-avoid-endl,performance-faster-string-find,performance-for-range-copy,performance-implicit-conversion-in-loop,performance-inefficient-*,performance-move-*,performance-no-*,performance-noexcept-*,performance-trivially-destructible,performance-type-promotion-in-math-fn,performance-unnecessary-*,portability-*,readability-avoid-*,readability-braces-around-statements,readability-const-return-type,readability-container-contains,readability-container-data-pointer,readability-convert-member-functions-to-static,readability-delete-null-pointer,readability-duplicate-include,readability-else-after-return,readability-enum-initial-value,readability-identifier-naming,readability-implicit-bool-conversion,readability-inconsistent-declaration-parameter-name,readability-isolate-declaration,readability-make-member-function-const,readability-misleading-indentation,readability-misplaced-array-index,readability-named-parameter,readability-non-const-parameter,readability-operators-representation,readability-qualified-auto,readability-redundant-*,readability-reference-to-constructed-temporary,readability-simplify-subscript-expr,readability-static-*,readability-string-compare,readability-suspicious-call-argument,readability-uniqueptr-delete-release,readability-use-*
This enables all the common checks and stops clang-tidy from complaining about raw pointers or not using auto. Only blur blurs use auto.
We then go to Analyze › Clang-Tidy and select the whole project for analysis. After clicking "Analyze" in the pop up window, clang-tidy will run. We then wait for the results.
/home/infinityintegral/ColoursPlusPlus/src/main.cpp:5:6: warning: function 'init' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage] 1: static in /home/infinityintegral/ColoursPlusPlus/src/main.cpp:5
Only 1 thing to fix, this means that our code is actually quite good.
To see what clang-tidy is complaining about, we look at the name of the check. In this case, it is misc-use-internal-linkage, which essentially means I should put inline functions in a anonymous namespace. You should search the name of the check online if its meaning is unclear.
Then for each issue found, we go to the code to see if it really needs fixing. If fixing it improves your code, you should fix it. Otherwise, you can mark it as NOLINT to ignore it.
Here, it really does not matter, so we can ignore it using NOLINT.
void init(){ //NOLINT(misc-use-internal-linkage) SGXCentral::applicationName = "Colours++ - a SGEXTN demo app"; SGXCentral::applicationVersion = "v2.0.0"; SGXCentral::organisationName = "05524F.sg (Singapore)"; SGXCentral::folderName = "ColoursPlusPlus"; SGXCentral::customInitialise = &SGCLPIntroductionPage::activate; }
If we look at the raw output of clang-tidy after running it again, it should be something like this
20:31:26: Running Clang-Tidy on /home/infinityintegral/ColoursPlusPlus/CMakeLists.txt with configuration "05524F". Analyzing "/home/infinityintegral/ColoursPlusPlus/src/SGCLPDisplayPage.cpp" [Clang-Tidy]. Analyzing "/home/infinityintegral/ColoursPlusPlus/src/SGCLPIntroductionPage.cpp" [Clang-Tidy]. 20:31:26: Clang-Tidy produced stderr output: 1 warning generated. Suppressed 1 warnings (1 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. Analyzing "/home/infinityintegral/ColoursPlusPlus/src/SGCLPOptionsPage.cpp" [Clang-Tidy]. 20:31:26: Clang-Tidy produced stderr output: 1 warning generated. Suppressed 1 warnings (1 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. Analyzing "/home/infinityintegral/ColoursPlusPlus/src/main.cpp" [Clang-Tidy]. 20:31:26: Clang-Tidy produced stderr output: 1 warning generated. Suppressed 2 warnings (1 in non-user code, 1 NOLINT). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 20:31:26: Clang-Tidy produced stderr output: 1 warning generated. Suppressed 1 warnings (1 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 20:31:26: Clang-Tidy finished: Processed 4 files successfully, 0 failed. 20:31:26: Elapsed time: 00:00.
Note how only 1 issue was found in each file. That check is suppressed because it is not in your code, it may be inside clang-tidy's own code, the environment code, or SGEXTN code.
This is one of the biggest advantages of using SGEXTN. The SGEXTN header files are really clean. If you were to use the Standard Template Library or Qt directly, you would be looking at thousands of issues per file and clang-tidy scanning time can be more than 10 times of that if you use SGEXTN.
Now with our code approved by clang-tidy, we can send it onto GitHub.
git add . git commit -m "done options page" git push
See here for the next part of the tutorial.
©2025 05524F.sg (Singapore)