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 20 6091
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
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
On May 10, 1:34 pm, Michael Holm <MichaelH...@thismaildontwork.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
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
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
"Michael Holm" <Mi*********@thismaildontwork.comha scritto nel messaggio
news:464381b7$0$14044
Any pointers are highly appreciated.
void *p;
Massimo
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
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
>Any pointers are highly appreciated.
>
void *p;
Massimo
hehe :)
Michael Holm wrote:
>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?
Connect to 'msnews.microsoft.com' server. They carry all the stuff
you will need.
Connect to 'msnews.microsoft.com' server. They carry all the stuff
you will need.
Thanks :)
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?
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
Microsoft has a _strdup function (notice the leading underscore).
They used to have a "#define" that defined "strdup" as "_strdup",
but in their later compilers they have removed that define.
You could add the define yourself, or you could change the
source code to use _strdup.
Microsoft's latest compilers now issue "deprecated" warnings
for many ANSI/POSIX functions (all of the str... functions
for example). There is a define (_CRT_NONSTDC_NO_DEPRECATE)
you can add to turn off those warnings, or you can use the
"/wd4996" compiler switch.
Microsoft wants folks to use their new, non-standard,
functions in place of the ANSI/POSIX functions.
They say for safety, but if you use their new functions
your code will be Windows-specific (non-portable).
You can search www.msdn.com for "Deprecated POSIX functions"
to find a table listing all of the 100+ C Runtime (CRT) and
POSIX functions that Microsoft is now calling "deprecated".
On May 10, 10:41 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
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.
It's part of the Standard Unix specification, so one could
consider it "standard". Just not the right standard for this
group:-).
More to the point, his error message indicates a file with a .y
extension. This suggests code generated by yacc or one of its
relatives (e.g. bison). A priori, I'm not sure that such tools
guarantee "portable" code; it might simply be that he has to run
the tool on his target platform. (The code generated by bison
seems OK, however. No strdup there. Note, however, that by
default, it generates C, and not C++. So there could be
problems in that regard as well.)
Also, because C and C++ forbid the presence of strdup in
<string.h>, but other standards require it, it's presence will
often depend on compiler flags. He should check his compiler
documentation to see if he needs special flags or defines along
the lines of XOPEN_SOURCE, or whatever.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On May 10, 11:09 pm, Michael Holm <MichaelH...@thismaildontwork.com>
wrote:
[...]
These POSIX functions are deprecated beginning in Visual C++ 2005. Use
the ISO C++ conformant _strdup, _wcsdup, _mbsdup instead.
None of which made sense.
That last line makes a lot of sense (although technically it's
wrong: strdup is not Posix, but Unix---which is a superset of
Posix). Basically, they've decided to conform to the C/C++
standards, and are deprecating the functions which were
previously in <string.h>, but which don't belong there according
to the C/C++ standards. And are renaming them using a name in
the implementation reserved namespace.
It also means that the functions are still available, so you
should find them, if you include <string.h>. (They're present
in VC++ 2005, although they cause a warning by default.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On May 10, 11:22 pm, Michael Holm <MichaelH...@thismaildontwork.com>
wrote:
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)
I'd get rid of the STL port. The quality is considerably less
than that of the standard library delivered with VC++. (FWIW:
standard conforming code, not addressing the system API, seems
to port without problems between g++ 4.x and VC++ 2005.)
For any real portability issues, I'd look for some sort of a
intermediate library to mask them. Something like wxWidgets,
Boost::threads, or whatever you happen to need.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On May 11, 2:02 am, Larry Smith <lsm...@nospam.comwrote:
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?
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.
Microsoft has a _strdup function (notice the leading underscore).
They also have an strdup function, at least in VC 2005.
They used to have a "#define" that defined "strdup" as "_strdup",
but in their later compilers they have removed that define.
You could add the define yourself, or you could change the
source code to use _strdup.
Microsoft's latest compilers now issue "deprecated" warnings
for many ANSI/POSIX functions (all of the str... functions
for example). There is a define (_CRT_NONSTDC_NO_DEPRECATE)
you can add to turn off those warnings, or you can use the
"/wd4996" compiler switch.
The define does NOT turn off the warnings for Posix functions;
only those functions in ISO C which have a replacement in the
ISO C TR.
Microsoft wants folks to use their new, non-standard,
functions in place of the ANSI/POSIX functions.
They say for safety, but if you use their new functions
your code will be Windows-specific (non-portable).
Well, given that the replacement functions are in a TR defined
by the C standards committee, one would hope that they would be
supported by any up to date C compiler. (Of course, in
practice, even C99 is only supported about like C++ 98 with
export. So "up to date C compiler" is probably a contradiction
in itself.)
The function in question, strdup, has never been part of
standard C/C++, and its presence in <string.his forbidden by
both ISO standards. In practice, of course... all of the
compilers I have access to do include it, by default at least.
So much for standards compliance.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
James Kanze wrote:
On May 11, 2:02 am, Larry Smith <lsm...@nospam.comwrote:
>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?
>>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.
>Microsoft has a _strdup function (notice the leading underscore).
They also have an strdup function, at least in VC 2005.
>They used to have a "#define" that defined "strdup" as "_strdup", but in their later compilers they have removed that define. You could add the define yourself, or you could change the source code to use _strdup.
>Microsoft's latest compilers now issue "deprecated" warnings for many ANSI/POSIX functions (all of the str... functions for example). There is a define (_CRT_NONSTDC_NO_DEPRECATE) you can add to turn off those warnings, or you can use the "/wd4996" compiler switch.
The define does NOT turn off the warnings for Posix functions;
only those functions in ISO C which have a replacement in the
ISO C TR.
>Microsoft wants folks to use their new, non-standard, functions in place of the ANSI/POSIX functions. They say for safety, but if you use their new functions your code will be Windows-specific (non-portable).
Well, given that the replacement functions are in a TR defined
by the C standards committee, one would hope that they would be
supported by any up to date C compiler. (Of course, in
practice, even C99 is only supported about like C++ 98 with
export. So "up to date C compiler" is probably a contradiction
in itself.)
The function in question, strdup, has never been part of
standard C/C++, and its presence in <string.his forbidden by
both ISO standards. In practice, of course... all of the
compilers I have access to do include it, by default at least.
So much for standards compliance.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
strdup is a POSIX Standard (IEEE Std 1003.1-2001) function.
As a Unix/Linux developer working with a cross-platform
codebase (Windows, AIX, Solaris, Linux), the POSIX functions
are important to me.
Larry Smith wrote:
strdup is a POSIX Standard (IEEE Std 1003.1-2001) function.
As a Unix/Linux developer working with a cross-platform
codebase (Windows, AIX, Solaris, Linux), the POSIX functions
are important to me.
That may be so, but it doesn't make POSIX functions topical here.
Brian
On May 12, 12:15 am, Larry Smith <lsm...@nospam.comwrote:
James Kanze wrote:
[...]
The function in question, strdup, has never been part of
standard C/C++, and its presence in <string.his forbidden by
both ISO standards. In practice, of course... all of the
compilers I have access to do include it, by default at least.
So much for standards compliance.
strdup is a POSIX Standard (IEEE Std 1003.1-2001) function.
The must have removed it since then, then, since in the on-line
version of IEEE Std 1003.1-2004, it is documented as an "X/Open
System Interfaces Extension"---standard Unix, but not Posix.
As a Unix/Linux developer working with a cross-platform
codebase (Windows, AIX, Solaris, Linux), the POSIX functions
are important to me.
Linux isn't really Posix compliant (and doesn't claim to be),
although it does support much of both Posix and the X/Open
System extensions. Windows from what I've seen, has a Posix
compatible layer, but it is for all practical purposes
unusable---it's just there to be able to claim Posix compliance
when that is required. And Solaris isn't really Posix compliant
by default, either; you need to use special options with the
compiler.
Posix helps, but it isn't really a guarantee. (In this, it's no
different than the C++ standard, which is ignored by most of the
major vendors whenever they find it convenient.)
--
James Kanze (Gabi Software) email: ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
* James Kanze:
Windows from what I've seen, has a Posix
compatible layer, but it is for all practical purposes
unusable---it's just there to be able to claim Posix compliance
when that is required
I think what you mean is that Windows C++ compilers typically provide a
bunch of Posix functions.
That's different from Posix compatibility. Windows had a Posix
compatibility layer, for Posix 0.9, from Windows NT 3.5 or thereabouts,
but that worked as a console program environment sort of isolated from
the rest of Windows. However, AFAIK it's removed in Windows XP, and
instead one can run a free *nix environment provided by Microsoft.
Of course that doesn't have much to do with C++, except that the MS *nix
environment includes the open source g++ compiler.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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)),...
|
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>
|
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>
|
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...
| |
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 .."...
|
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
|
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,...
|
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...
|
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,...
|
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...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |