On May 10, 1:34 pm, Michael Holm <MichaelH...@th ismaildontwork. com>
wrote:
Ever so often when I try to compile some open source code, I get a error,
pbrtparse.y(205 ) : error C3861: 'strdup': identifier not found
In the example, I'm trying to compile pbrt (http://www.pbrt.org/).
And I have been searching all over the net for it, and it seems I'm the
only one having a problem with strdup.
What do I do wrong?
<OT>
If your keyboard has an F1 key, perhaps you could use it. If not, get
a new keyboard, or use your mouse to go to the Help menu, and search
for 'C3861'. (MSVC has truly wonderful help functionality, once you
learn to use it.) You'll see that the error message you're getting
means that the identifier 'strdup' has not been declared.
(Admittedly, you might have made an educated guess based on the error
message you're getting.)
</OT>
So in other words, the problem is that the declaration of strdup is
not being seen by the code you're trying to compile.
So where is the declaration of strdup?
At this point, use F1/Help and look up 'strdup', and you'll find that
it's in <string.h>, at least on Windows. Update the code you have to
#include <string.h (Note: this is different from <string>.)
Now you may get a warning message that strdup is deprecated, and you
should use _strdup instead. If you do, you could potentially read the
help on this warning, or, since you're too pressed for time, here's
the answer: depending on your intentions, you can either ignore the
warning, shut the warning off, or change the code to use _strdup
(perhaps #define strdup _strdup).
Michael