![]() |
|
#1
|
|||
|
|||
problem with includeAs soon as I take this function out of main and put it in another file named html.cpp it gives me this error: error: string was not declared in this scope.
It does this on the void proc_html line... CPP / C++ / C Code:
Last edited by LuciWiz : 03-Jul-2005 at 23:33.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|||
|
#2
|
|||
|
|||
|
Quote:
Each file is a separate compilation unit. If a file uses strings, the string header must be #included in that file. You should use standard headers. Note that the C header <string.h> contains functions like strcpy(), strcat(), etc. When this header is used with C++, you should #include <cstring>, not <string.h>. Also when using the functions in the C header <stdio.h> in a C++ program, you should #include <cstdio>. Similarly, other C library headers, like <ctype.h> are renamed for c++ to things like <cctype>. Note that the C++ string class and its functions are defined in the C++ header <string>, not <string.h>, and not <cstring>. There are a few other issues that you must be at least aware of with the C++ headers. These headers define functions that are in a special namespace, called std. So, the front end of your files might look like this: CPP / C++ / C Code:
Of course you only neet whatever headers are needed by the library functions and classes in that particular file. If you have been using the c-style headers in your c++ programs and they seem to have been working, it's something that compilers up until now have been supporting, but they may not do so in the future. That's why I urge you to start using standard C++ headers. Regards, Dave |
|
#3
|
|||
|
|||
|
All my includes are in that file too.. I even included the proto. I'm on Mac OS X and none of those libraries that you suggested appear to exist.
|
|
#4
|
|||
|
|||
|
Quote:
I'm sorry; I was referring to Standard C and Standard C++. I don't have access to a Mac for testing, but since OS X is based on freeBSD, I am quite sure that standard C and Standard C++ headers must be available. If you can't #include <cctype>, for example, then I think that either your installation is broken, or you don't have proper environment variables set up for compilation and linking. Maybe someone else reading this thread can help. Sorry. Regards, Dave Last edited by davekw7x : 03-Jul-2005 at 22:22.
|
|
#5
|
|||
|
|||
|
CPP / C++ / C Code:
I changed these and got the same error. Last edited by LuciWiz : 03-Jul-2005 at 23:35.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#6
|
|||
|
|||
|
Quote:
Did you put the following line after the #includes? CPP / C++ / C Code:
Regards, Dave |
|
#7
|
|||
|
|||
|
I put that in there, still nothing.
|
|
#8
|
|||
|
|||
|
Quote:
If I understand the problem so far: 1. You can make a program with everything in a single file that uses C++ strings. 2. When you put some functions in one file and others in a different file, the only compiler error message is that string is undefined in the scope for one of the files. Let's try this: Make two small files that illustrate this problem and post them. Copy and paste the actual source text into your response Use code tags, as shown here: Guidelines for posting requests for help Tell me how you compile and link the files on the Mac. I can't recreate your environment, but I may be able to tell what's happening. No guarantees, but I don't mind trying (until someone on this forum with a Mac jumps in and gives you specific advice). Regards, Dave |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| savings account problem | ap6118 | C++ Forum | 5 | 01-Apr-2005 10:37 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 08:10 |
| help with classes | bucho | MS Visual C++ / MFC Forum | 3 | 20-Oct-2004 07:16 |
| Hmm what seems to be the problem here? error C2061: syntax error | pablowablo | C++ Forum | 5 | 12-Jun-2004 23:11 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The