msvc和strdup? [英] msvc and strdup?

查看:122
本文介绍了msvc和strdup?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试编译一些开源代码时,我经常遇到错误,


pbrtparse.y(205):错误C3861:''strdup'':标识符没找到


在这个例子中,我正在尝试编译pbrt( http://www.pbrt.org/)


我一直在网上搜索它,看起来我好像是

只有一个人遇到strdup问题。


我做错了什么?


我怀疑这可能是我的装置'假的,但我想在格式化我的C:\ :)之前听到你的意见
$

任何指针都非常受欢迎。


- 迈克尔

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?

I suspect it could be my installation that''s bogus, but I''d like to hear
your opinions before formatting my C:\ :)

Any pointers are highly appreciated.

--Michael

推荐答案

Michael Holm写道:
Michael Holm wrote:

我经常尝试编译一些开源代码,我得到一个

错误,

pbrtparse.y (205):错误C38 61:''strdup'':未找到标识符


在示例中,我正在尝试编译pbrt( http://www.pbrt.org/)


我一直在搜索网吧,看来我是

唯一一个遇到strdup问题的人。


我做错了什么?
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?



您正在使用非可移植代码,希望它能轻松移植。它没有,你会感到惊讶......


''strdup''是一个非标准功能。 RTFM可能的更换。

You''re using non-portable code hoping that it would port easily. It
doesn''t, and you get surprised....

''strdup'' is a non-standard function. RTFM for a possible replacement.


我怀疑这可能是我的安装'那是假的,但我想

在格式化我的C之前听到你的意见:\ :)
I suspect it could be my installation that''s bogus, but I''d like to
hear your opinions before formatting my C:\ :)



您的C:​​\可能仍然会受益于格式化。 :-)


V

-

请在通过电子邮件回复时删除资金''A' br />
我没有回复最热门的回复,请不要问

Your C:\ might still benefit from formatting. :-)

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


你正在使用不可移植的代码希望它很容易移植。它
You''re using non-portable code hoping that it would port easily. It

不行,你会感到惊讶....
doesn''t, and you get surprised....



好​​吧,我下载了win32版本的源代码,为msvc(一个.sln文件)预先制作了

解决方案,所以我不确定'是正确的

解释。 ?


- 迈克尔

Well, I downloaded the win32 version of the source code, with a pre-made
solution for msvc (a .sln file) so I''m not sure that''s the correct
explanation. ?

--Michael


5月10日下午1点34分,Michael Holm< MichaelH ... @ thismaildontwork .com>

写道:
On May 10, 1:34 pm, Michael Holm <MichaelH...@thismaildontwork.com>
wrote:

我经常尝试编译一些开源代码,我收到一个错误,


pbrtparse.y(205):错误C3861:''strdup'':未找到标识符


在示例中,我正在尝试编译pbrt( http://www.pbrt.org/)


我一直在网上搜索它,看起来我只是一个有strdup问题的人。


我做错了什么?
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>

如果您的键盘有F1键,也许您可​​以使用它。如果没有,请使用新键盘获取

,或者使用鼠标转到帮助菜单,然后搜索
中的C3861。 (MSVC拥有真正出色的帮助功能,一旦你学会使用它,你就会看到。)你会看到你得到的错误信息

意味着标识符''strdup''尚未宣布。

(不可否认,你可能根据错误

消息进行了有根据的猜测。)

< / OT>


换句话说,问题是strdup的声明是

没有看到代码你试图编译。


那么strdup的声明在哪里?


此时,使用F1 /帮助和查找''strdup'',你会发现

它位于< string.h>,至少在Windows上。更新你需要的代码

#include< string.h(注意:这与< string>不同。)


现在你可能会得到一个警告消息,strosed已被弃用,而你

应该改为使用_strdup。如果你这样做,你可能会在这个警告上阅读

帮助,或者,因为你的时间太紧了,这里的答案是:b $ b答案:依赖根据你的意图,你可以忽略

警告,关闭警告,或者更改代码以使用_strdup

(也许是#define strdup _strdup)。


Michael

<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


这篇关于msvc和strdup?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆