Open Atreyagaurav opened 2 weeks ago
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
For more context:
The compilation failed with the following error on Arch Linux for strcasestr
function, so this fix prevents it from being redefined:
src/Utilities/verticalDatum.c:43:13: error: conflicting types for ‘strcasestr’; have ‘const char *(const char *, const char *)’
43 | const char* strcasestr(const char* haystack, const char* needle) {
| ^~~~~~~~~~
In file included from src/Utilities/verticalDatum.c:2:
/usr/include/string.h:380:14: note: previous declaration of ‘strcasestr’ with type ‘char *(const char *, const char *)’
380 | extern char *strcasestr (const char *__haystack, const char *__needle)
| ^~~~~~~~~~
make[1]: *** [Makefile:35: Output/./src/Utilities/verticalDatum.c.o] Error 1
make[1]: Leaving directory '/home/.../hec-dss/heclib/heclib_c'
make: *** [Makefile:25: all] Error 2
Hi @Atreyagaurav , thanks for posting.
Do the tests all pass with your change on your OS?
Based on the error message, It might work to remove the const keyword in verticalDatum.c
from:
const char* strcasestr(const char* haystack, const char* needle)
to:
char* strcasestr(const char* haystack, const char* needle)
I tried without my change and with my change, both cases I get an error on one test case, but this seems to be related to test/C/v6-pc.dss
file.
That doesn't work either, I get error: return discards ‘const’ qualifier from pointer target type
. Plus if the function is already defined in strings.h
, I think it's best to remove it using preprocessor. Although I don't know if different linux distro have different versions of strings.h
(with and without this function), if it has been working so far in linux distro you guys have tested on, it could be because of that reason.
I couldn't compile the hec-lib on Linux, so I have fixed some of the issues. These are minor changes that should not break anything but please do check compiling it on other platforms with this before merging.