Archived

This topic is now archived and is closed to further replies.

billybob

string.h will not include NO MATTER WHAT

Recommended Posts

i''ve resorted to including every single include file i can think of because no matter what the compiler says strlen, strcpy, and strcat are undefined identifiers. i''ve included string.h, stdio.h, iostream, iostream.h, stdlib, and many many many more. but it still just says those three are undefined! what is going on?!

Share this post


Link to post
Share on other sites
1) Are you getting a compiler error or a linker error ?

2) What is the EXACT error message the compiler is giving you - "it says there are undeclared identifiers" doesn''t tell us enough to give any exact help.

3) Which compiler?, MSVC?, DevC?, GCC?, ProDG?, CodeWarrior?, Lattice?, Easy?, Watcom?, etc...?, which version?

4) Post some code - maybe something in an earlier header, or an incorrect pragma in your code or a bad define etc is causing those to not actually be included.

5) If the error is actually a linker error, check that you haven''t been playing with the linker options and done something like Ignore All Default Libraries or changed the version of the CRT in use.

6) Are you using anything like MiniCRT (i.e. trying to make a tiny .exe and so changing the default compile behaviours)

7) Have you recently installed a new version of the Platform SDK ? - make sure its environment variables have been set up and its entries are in the Tools->Options->Directories list (assuming MSVC...)

8) Check the Tools->Options->Directories anyway to make sure there are entries in there for lib files.


I reckon it''s probably something wrong near the top of your source code file unless you''ve been fiddling with compiler options.

500x3

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
If you mean the C string header, and you''re using a C++ compiler, you''ll need to

#include <cstring
using namespace std;

The C++ spec requires that these C headers be made available in the std namespace with a c prefix and no .h suffix. Most compilers also let you use string.h, stdlib.h, etc., but don''t count on it.


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
error C2065: 'strlen' : undeclared identifier
error C2065: 'strcpy' : undeclared identifier
error C2065: 'strcat' : undeclared identifier

i got really annoyed so i went and just found a string class and copied it into C++, including all the headers. i get the same thing on this:

http://www.decompile.com/html/invalid_pointer_addition.html

i copied that program, the fixed one down below, directly into my program, which is MSVC 6. i get it on that program also

its a borland program, but the string.h is a standard header i thought?

[edited by - billybob on December 24, 2002 5:52:00 PM]

Share this post


Link to post
Share on other sites
2 possibilities:

1. you are including the C++ version and not using the std:: namespace identifier (unlikely). I personally would try including "cstring" and adding a line "using namespace std;"

2. your compiler paths are screwed up, and it cannot find the correct file. IF you have added any paths to your comipler, make sure there is not some crappy file named "string" "string.h" "cstring" or "cstring.h" in them ... because you want the built in libraries ...

Share this post


Link to post
Share on other sites
Or possibility 3, something is misconfigured with your MSVC installation.

Or possibility 4, something up with your precompiled headers (e.g. you''re including a stdafx.h somewhere and the required headers aren''t in it).

I just visited that site and the code builds fine for me with MSVC (with the November 2001 Platform SDK, but that won''t matter). What I did:

1) Open DevStudio
2) Select New->Projects and choose Win32 Console Application
3) Set a name and path
4) Select "An empty project" from the "what kind of console application" dialog.
5) Finish, Ok
6) File->New...->C++ Source File - blah.cpp
7) Copy code from that site into blah.cpp (no other contents in file)
8) remove the condefs.h #include since that file doesn''t exist in MSVC
9) Hit F7 to build -:

Compiling...
blah.cpp
e:\projects\experiments\moo\blah.cpp(73) : warning C4068: unknown pragma
Linking...

moo.exe - 0 error(s), 1 warning(s)



The unknown pragma is simply complaining about the Borland argsused, it''s only used in that code to prevent a warning on Borland compilers.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
I recently had a problem with wanting to use getch() within a C++ program, where didn''t have it. What I had to do was include the original file (where getch() is defined), but put ''extern "C" {'' around it for it to fit in, like so:

extern "C" {
#include <conio.h>
}

and then the rest of my headers, and so forth. It worked fine. Perhaps you''d like to do that?

Twilight Dragon

Share this post


Link to post
Share on other sites