[m-users.] Compiler warning in my readdir.m

Volker Wysk post at volker-wysk.de
Mon Oct 14 15:14:05 AEDT 2019


Am Montag, den 14.10.2019, 06:08 +0200 schrieb Volker Wysk:
> Hi
> 
> There might be an issue in my fixed version of readdir.m. When
> building
> the module, I get a compiler warning:
> 
> Making Mercury/os/readdir.o
> readdir.m: In function ‘readdir_module0’:
> readdir.m:70:18: warning: assignment discards ‘const’ qualifier from
> pointer target type [-Wdiscarded-qualifiers]
> readdir.m: In function ‘readdir_module1’:
> readdir.m:70:18: warning: assignment discards ‘const’ qualifier from
> pointer target type [-Wdiscarded-qualifiers]
> 
> This is in the C code at this place (the line in the middle):
> 
>         if (errno == 0) {
>            Entry = \"\";
>            Result = 0;
> 
> I've attached the complete file.
> 
> Changing the 'Entry =' line to 'Entry = (char*) \"\"' avoids the
> warning message. I guess it's not an error, but I'm not completely
> sure. I'm not experienced with the foreign language interface (yet).
> Maybe it's the type of "Entry" should be "char * const", rahter than
> "char *".

Sorry, that should be "char const *", or (this is the same) "const char
*", not "char * const".

Bye
Volker



More information about the users mailing list