Closed SilvanScherrer closed 2 years ago
Sorry but I can't see the problem so far. This simple test doesn't give any clashes:
#include <stdio.h>
#include <unistd.h>
#include <crypt.h>
int main(void)
{
printf ("%p\n", crypt);
return 0;
}
hmm g++ -c -Zomf unistd.c -Ic:/usr/include -o unistd.o triggers the error. Why does adding usr/include trigger it?
Are you talking about the above test case? This doesn't trigger any problems here. May be something is wrong with your include dir...
Discard my last comment, I could reproduce it too (had crypt.h commented out).
This happens because -Ic:/usr/include
makes LIBC includes to be included before their GCC overrides from C:\usr\lib\gcc\i686-pc-os2-emx\9\include-fixed
and this somehow breaks some GCC setup in C++ mode. It's not clear what exactly gets broken because there is no source-level difference between preprocessor results of both cases in -E mode except some # <num> <file>
references to included files but apparently these references somehow change the GCC behavior. If I remove all lines starting from #
both cases fail similarly:
test.E1f.c:913:14: error: declaration of 'char* crypt(const char*, const char*) throw ()' has a different exception specifier
913 | extern char *crypt (const char *__key, const char *__salt)
| ^~~~~
test.E1f.c:736:7: note: from previous declaration 'char* crypt(const char*, const char*)'
736 | char *crypt(const char *, const char *);
| ^~~~~
test.E1f.c:917:13: error: declaration of 'void setkey(const char*) throw ()' has a different exception specifier
917 | extern void setkey (const char *__key) throw () __attribute__ ((__nonnull__ (1)));
| ^~~~~~
test.E1f.c:805:6: note: from previous declaration 'void setkey(const char*)'
805 | void setkey(const char *);
| ^~~~~~
test.E1f.c:921:13: error: declaration of 'void encrypt(char*, int) throw ()' has a different exception specifier
921 | extern void encrypt (char *__block, int __edflag) throw () __attribute__ ((__nonnull__ (1)));
| ^~~~~~~
test.E1f.c:738:6: note: from previous declaration 'void encrypt(char*, int)'
738 | void encrypt(char *, int);
| ^~~~~~~
Given that iIn general a practice of manually adding top-level system include dirs to the GCC command line is bad (and may lead to many other problems), I guess we should fix the project that does that instead of fixing anything in LIBC or GCC.
remove crypt() and encrypt() from unistd.h, as they are defined in crypt.h. This might give a clash if both .h are included