473,651 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

msvc and 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?

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
May 10 '07 #1
20 6115
Michael Holm 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?
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.
I suspect it could be my installation that's bogus, but I'd like to
hear your opinions before formatting my C:\ :)
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
May 10 '07 #2
You're using non-portable code hoping that it would port easily. It
doesn't, and you get surprised....
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
May 10 '07 #3
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
May 10 '07 #4
Michael Holm wrote:
>You're using non-portable code hoping that it would port easily. It
doesn't, and you get surprised....

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. ?
This is off-topic here (look for VC++ newsgroup), but are you sure
you're using the _same_version_ of VC++ as the one specified in the
build instructions? 'win32' is not a promise of portability to any
VC++ version...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 10 '07 #5
Thanks for your answer.

I did press F1, and found this:

Function Information

Minimum DLL Version shlwapi.dll version 4.71 or later
Custom Implementation No
Header shlwapi.h
Import library shlwapi.lib
Minimum operating systems Windows 2000, Windows NT 4.0 with Internet
Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0
Unicode Implemented as ANSI and Unicode versions.
and

Strings.StrDup Method

and

Run-Time Library Reference
strdup, wcsdup

Language Filter: All Language Filter: Multiple Language Filter: Visual
Basic Language Filter: C# Language Filter: C++ Language Filter: J#
Language Filter: JScript
Visual Basic (Declaration)
Visual Basic (Usage)
C#
C++
J#
JScript

These POSIX functions are deprecated beginning in Visual C++ 2005. Use
the ISO C++ conformant _strdup, _wcsdup, _mbsdup instead.

None of which made sense.

So - thanks alot - I'll try again :)

//Michael
May 10 '07 #6
"Michael Holm" <Mi*********@th ismaildontwork. comha scritto nel messaggio
news:464381b7$0 $14044
Any pointers are highly appreciated.
void *p;
Massimo

May 10 '07 #7
Hmmm, It may be that I have compiled/installed stlport wrong. When
including <string.hI get the sltport version of string.h, and not the
windows one.
I don't want to remove stlport, as I use it for some cross-platform
stuff (linux)

Does that spawn any thoughts?

--Michael
May 10 '07 #8
This is off-topic here (look for VC++ newsgroup), b
Searching my news server, I don't see any "vc" or "vc++" or msvc groups,
do you know one by exact name?

I have no wish to be off-topic, and apologize.

--Michael
May 10 '07 #9
Connect to 'msnews.microso ft.com' server. They carry all the stuff
you will need.
Thanks :)
May 10 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
23623
by: Allan Bruce | last post by:
Hi there, I have a program written in c++ and I wish to use a similar function to strdup(). The reason I have problems is that the char array requires freeing to avoid a memory leak, but I get problems using delete; e.g. char *NewCharArray;
6
2935
by: Stefan Schwärzler | last post by:
Hi Ng, habe nicht besonders viel Erfahrung in C und C++, deshalb: möchte den befehl strdup in <string.h> verwenden. #include <string.h> attrib(char *name, char *val) : name(strdup(name)), val(strdup(val)), next(0) { CDEBUG(printf("attrib::attrib(%s, %s)\n", name, val)); }
32
6365
by: Grumble | last post by:
As far as I can tell, strdup() is neither in C89 nor in C99. Is that correct? <OT>Is it in POSIX perhaps?</OT>
37
4293
by: priya | last post by:
Hi all, I am using strdup() in my c program..But I am having some pr0blem while using the free() in my c code.here I am pasting the my code. #include <stdio.h>
53
651
by: klaushuotari | last post by:
Sorry to bother you, but I just have to. What about strdup()? It wasn't in standard C run-time library, yet many apps use it liberally as it was in there. I don't know if that particular function is included in C99. Not too difficult to code own version of it, but why it wasn't included in library in the first place? Is there some rationale behind it? There are peculiar and dangerous functions like strtok(), so why not strdup() which...
5
3338
by: lovecreatesbea... | last post by:
I am trying the FREE net-snmp library things. Like the FREE libxml++ library, it lacks of a reasonable document on its API. Its very begining example code compiles and runs. It says "blah blah .." when I substitute the host address for a snmp equipped machine ``192.168.5.10'' within our LAN like this: session.peername = strdup("192.168.5.10"); Is strdup still in use? Is there anything prevents the code from becoming these:
10
3913
by: thomas | last post by:
Hi, It's known that strdup() returns a char* type, but sometimes the following code generates warning messages. char *x = ... char *p = strdup(x); You must change it to
0
8357
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8277
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8803
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.