When I use strdup
in Microsoft Visual C++, it warns me:
warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
Thus it seems _strdup
is correct.
But when I use _strdup
in GCC (Fedora Linux OS), the compiler shows an error:
error: ‘_strdup’ was not declared in this scope
With GCC and Linux, compiler does not show any error for strdup
.
Which is correct - strdup
or _strdup
?
Note: I include <string.h>
in my code.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…