/* * To send data, function should not modify memory pointed to by `data` variable * thus `const` keyword is important * * To send generic data (or to write them to file) * any type may be passed for data, * thus use `void *` *//* OK example */voidsend_data(constvoid* dat...
Cppcheck是一个用于C/C++代码的静态分析工具,它可以帮助开发者检测代码中的错误。Cppcheck可以检测出许多类型的错误,包括语法错误、未使用的函数、内存泄漏、未初始化的变量等。此外,Cppcheck还支持用户自定义规则,这使得开发者可以根据自己的需求定制Cppcheck的行为。 主要选项 错误(error):这是最严重的问题,Cppcheck...
在Cppcheck中,内存泄漏检查是默认启用的。这意味着,即使你没有指定任何参数,Cppcheck也会检查内存泄漏。这是因为内存泄漏是一种严重的问题,所以Cppcheck默认总是检查它。 Cppcheck是一个静态分析工具,它可以检查C/C++代码中的多种类型的内存泄漏,包括但不限于: 未释放的内存:当程序使用malloc、calloc、realloc或new...
Cache Variable缓存变量相当于一个全局变量,在同一个CMake工程中任何地方都可以使用,比如父目录,子目录等,而如上文中缓存变量的指令格式是set(<variable> <value>... CACHE <type> <docstring> [FORCE]) # variable:变量名称 # value:变量值列表 # CACHE:cache变量的标志 # type:变量类型,取决于变量的值。...
Check if there is 64-bit portability issues: assign address to/from int/long Auto Variables A pointer to a variable is only valid as long as the variable is in scope. Check: returning a pointer to auto or temporary variable assigning address of an variable to an effective parameter of a ...
templatevoid f(T::type) { } struct A { }; void g() { A a; f(a); } $ gcc-4.9 t.cc t.cc:1:33: error: variable or field 'f' declared void templatevoid f(T::type) { } ^ t.cc: In function 'void g()': t.cc:6:5: error: 'f' was not declared in this scope ...
CERT.PUTENV.AUTO_VARIABLE 不要使用指向自动变量的指针作为参数来调用 putenv() 4 False 2022.1 CERT.STDLIB.SIGNAL 不得从计算异常信号处理程序返回 4 False 2022.2 CERT.VA_ARG.TYPE 不要通过类型错误的参数来调用 va_arg 4 False 2022.2 CERT.VA_START.TYPE 将类型正确的对象传递给 va_start 4 False 2022.2...
//macOS,XCodeintprintf(constchar* __restrict, ...)__printflike(1,2);//Windows,Visual Studio_Check_return_opt_ _CRT_STDIO_INLINEint__CRTDECLprintf( _In_z_ _Printf_format_string_charconst*const_Format, ...)intprintf(constchar* format , [argument] ... ); ...
char b; /* Wrong, variable with char type already exists */ char a, b; /* OK */ } 按顺序声明局部变量 i. 自定义结构和枚举 ii. 整数类型,更宽的无符号类型优先 iii. 单/双浮点 int my_func(void) { /* 1 */ my_struct_t my; /* First custom structures */ ...
Cppcheck是一个C/C++代码分析工具,只检测那些编译器通常无法检测到的bug类型。 官方上建议让编译器提供尽量多的警告提示: 1.使用Visual C++的话,应使用警告等级4 2.使用GCC的话,参看Warning options - using GCC 官方地址:http://cppcheck.sourceforge.net/ ...