#include <iostream>
#include <string.h>
char* basename(const char* filname);
int main()
{
return 0;
}
char *basename(const char* filename)
{
char* base = (char *)filename;
return base ;
}
compiling on g++ 4.1.2 20070115 (SUSE 10): No issue
compiling on g++ 4.3.4 (SUSE 11) gives following error
fileName : 9 :error:declaration of char* basename(const char*) throws different exception
fileName:3:error: from previous declaration char* basename(const char*) throw () .
Kindly tell me why this is happening , Is there is any Interface changed in g++ between these two release (if I remove inclusion of string.h then compilation success on both version of g++ ,Is any Interface change in string.h).
looks like basename already defined in string.h
# ifndef basename
/* Return the file name within directory of FILENAME. We don't
declare the function if the `basename' macro is available (defined
in <libgen.h>) which makes the XPG version of this function
available. */
# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++" char *basename (char *__filename)
__THROW __asm ("basename") __nonnull ((1));
extern "C++" __const char *basename (__const char *__filename)
__THROW __asm ("basename") __nonnull ((1));
# else
extern char *basename (__const char *__filename) __THROW __nonnull ((1));
# endif
# endif
It seems the name basename
already exists in string.h
:
#include <string.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With