I was using the library in platformio and I have encountered the following compiler warnings:
[{
"resource": "------------------ CSV Parser/CSV_Parser.cpp",
"owner": "cpp",
"severity": 4,
"message": "converting to non-pointer type 'int' from NULL [-Wconversion-null]",
"startLineNumber": 72,
"startColumn": 14,
"endLineNumber": 72,
"endColumn": 14
},{
"resource": "------------------ CSV Parser/CSV_Parser.cpp",
"owner": "cpp",
"severity": 4,
"message": "list-initializer for non-class type must not be parenthesized",
"startLineNumber": 77,
"startColumn": 3,
"endLineNumber": 77,
"endColumn": 3
},{
"resource": "------------------ CSV Parser/CSV_Parser.cpp",
"owner": "cpp",
"severity": 4,
"message": "converting to non-pointer type 'uint16_t' {aka 'short unsigned int'} from NULL [-Wconversion-null]",
"startLineNumber": 81,
"startColumn": 15,
"endLineNumber": 81,
"endColumn": 15
},{
"resource": "------------------ CSV Parser/CSV_Parser.cpp",
"owner": "cpp",
"severity": 4,
"message": "suggest parentheses around assignment used as truth value [-Wparentheses]",
"startLineNumber": 397,
"startColumn": 14,
"endLineNumber": 397,
"endColumn": 14
}]
I don't have the knowledge required to fully understand or test these AI suggested solutions, but I think they look relatively straightforward:
ln72: rows_count(NULL),
// AI suggests: rows_count(0),
// This warning typically arises when NULL is used to initialize or assign a value to an integer type. In modern C++, NULL is primarily used for pointers, and using it with integers is misleading because NULL is typically defined as ((void*)0), making it a null pointer, not an integer. Instead, you should use 0 or nullptr (for pointers only, not for integers).
ln77: delim_chars({'\r', '\n', delimiter_, 0}),
// AI suggests: delimchars{'\r', '\n', delimiter, 0},
// AI rationale: This warning occurs because you've used parentheses around a brace-enclosed initializer list for a non-class type (likely an array or a struct in your case). In C++, aggregate initialization should not be enclosed in parentheses.
ln81: current_col(NULL),
// AI suggests: current_col(0),
// AI rationale: Similar to the first warning, this is caused by assigning NULL to a non-pointer type, which in this case is uint16_t. If cols_count is meant to be an integer, initialize it with 0 instead of NULL:
ln397: while (val = parseStringValue(s, &chars_occupied)) {
// AI suggested while ((val = parseStringValue(s, &chars_occupied))) {
// AI rationale : This extra set of parentheses signals to the compiler that you are intentionally using an assignment in the condition, not mistakenly using an assignment when you meant to use a comparison.
Hello,
I was using the library in platformio and I have encountered the following compiler warnings:
I don't have the knowledge required to fully understand or test these AI suggested solutions, but I think they look relatively straightforward:
ln72: rows_count(NULL),
// AI suggests: rows_count(0), // This warning typically arises when NULL is used to initialize or assign a value to an integer type. In modern C++, NULL is primarily used for pointers, and using it with integers is misleading because NULL is typically defined as ((void*)0), making it a null pointer, not an integer. Instead, you should use 0 or nullptr (for pointers only, not for integers).ln77: delim_chars({'\r', '\n', delimiter_, 0}),
// AI suggests: delimchars{'\r', '\n', delimiter, 0}, // AI rationale: This warning occurs because you've used parentheses around a brace-enclosed initializer list for a non-class type (likely an array or a struct in your case). In C++, aggregate initialization should not be enclosed in parentheses.ln81: current_col(NULL),
// AI suggests: current_col(0), // AI rationale: Similar to the first warning, this is caused by assigning NULL to a non-pointer type, which in this case is uint16_t. If cols_count is meant to be an integer, initialize it with 0 instead of NULL:ln397: while (val = parseStringValue(s, &chars_occupied)) {
// AI suggested while ((val = parseStringValue(s, &chars_occupied))) { // AI rationale : This extra set of parentheses signals to the compiler that you are intentionally using an assignment in the condition, not mistakenly using an assignment when you meant to use a comparison.I hope this is useful. Thank you.