-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
This pragma is incompatible with older GCCs and CLANG:
Lines 590 to 593 in 870f110
| #pragma GCC diagnostic push | |
| #pragma GCC diagnostic ignored "-Wstringop-truncation" | |
| strncpy( gm, "EN", 2 ); | |
| #pragma GCC diagnostic pop |
[ 56s] nec2cpp.cpp: In function 'int readmn(FILE*, FILE*, char*, int*, int*, int*, int*, nec_float*, nec_float*, nec_float*, nec_float*, nec_float*, nec_float*)':
[ 56s] nec2cpp.cpp:591:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
[ 56s] #pragma GCC diagnostic ignored "-Wstringop-truncation"
The correct approach is to use strncpy(gm, "EN", 3); or memcpy(gm, "EN", 2); and remove the #pragma.
And the function signature can be changed to
int readmn(FILE*, FILE*, char[3], int*, int*, int*, int*, nec_float*, nec_float*, nec_float*, nec_float*, nec_float*, nec_float*).
This allows the compiler to check the array bounds at compile time.
Metadata
Metadata
Assignees
Labels
No labels