www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/01/03:28:07

Message-Id: <2.2.32.19970401134305.0068fc08@mailhost>
Mime-Version: 1.0
Date: Tue, 01 Apr 1997 11:43:05 -0200
To: djgpp AT delorie DOT com
From: Eyal Ben-David <eyalb AT aks DOT com>
Subject: Inacurate declaration of '_dos_findfirst()'

Hello.

The function  _dos_findfirst as declared in dos.h :

unsigned int _dos_findfirst(char* name,          /* should be "const char*
name"  */
                            unsigned int attr,
                            struct _find_t* result);

The problem is that in C++ I can't call this function with a "const char*" type
for the file name.

In C this is not a problem since the compiler can cast away constness
automatically.
In C++ this should be a compilation error. 

DJGPP GNU C++ compiler compiled this, but printed warnings.

I think the declaration should change to "const char* name". 
-- to prevent the above error.
-- to be compatible with other C functions that get  read-only strings.
-- the reader of the header file can deduce that the parameter name is not
   to be changed.


Eyal.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019