How to Use Tencent’s TscanCode for Static Code Analysis on Linux and Windows
This guide explains static code scanning concepts, compares popular tools, introduces Tencent’s open‑source TscanCode, details its supported languages and detection capabilities, and provides step‑by‑step instructions for running the tool on Linux and Windows with example code and results.
Static code scanning
Static code scanning analyzes source code without execution using lexical, syntactic, control‑flow and data‑flow techniques. It can detect mismatched parameters, ambiguous nesting, illegal recursion, null‑pointer dereferences, memory leaks, array out‑of‑bounds writes, and other hidden defects.
TscanCode
TscanCode is a Tencent‑developed static analysis tool. It originated from cppcheck and was later rewritten to support C/C++, C# and Lua. The tool can detect automatic variable misuse, out‑of‑bounds accesses, class‑constructor issues, memory leaks, null pointers and usage of deprecated functions.
https://github.com/Tencent/TscanCode
Package layout
release – compiled binaries for Linux, macOS and Windows.
samples – example source files for C++, C# and Lua.
trunk – source code of TscanCode.
Linux usage
The Linux binary is located at:
TscanCode-master/release/linux/TscanCodeV2.14.2395.linux
Make the binary executable: chmod +x TscanCodeV2.14.2395.linux Example 1: Scan C++ sample code
./TscanCodeV2.14.2395.linux --xml --enable=all -q ../../../samples/cpp/ >scan_result.xml 2>&1The command produces scan_result.xml, which can be opened with a spreadsheet viewer for a readable report.
Example 2: Scan a C file with an out‑of‑bounds write
#include <stdio.h>
void test(void)
{
char buf[5] = {0};
for (size_t i = 0; i < 10; i++)
{
buf[i] = 1; // out‑of‑bounds write
}
}
int main(int argc, char **argv)
{
test();
return 0;
}Run the scan:
./TscanCodeV2.14.2395.linux --xml --enable=all -q ./test.c >scan_result.xml 2>&1The generated report highlights the out‑of‑bounds write to buf.
Windows usage
Recent releases no longer include a Windows executable. Use version V2.14.24 (file TscanCodeV2.14.24.windows.exe) from the release archive.
https://blog.csdn.net/m0_53168002/article/details/126596565
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
