PDA

View Full Version : g++ questions



LackeyLad
13th June 2004, 03:31 AM
1. Does anyone know of a site where i can research why i get the -Wno deprecated messege on my g++? Something about not needed to add the .h precompiler libraries.

2. Also, i cant seem to compile anything that uses the # include <string> library. Why does that not compile with fedora g++?

ghaefb
13th June 2004, 03:39 AM
Maybe you forgot to write this line:

using namespace std;

And you wrote #include <string> right? (not # include <string>)

micha
13th June 2004, 03:40 AM
1. What is the error you get? Look at the gcc manual on the gcc web site, you might find some useful information. http://gcc.gnu.org

2. The C++ Standard Library (including <string>) works well for me. Make sure that everything related to gcc and C++ library is installed.

--Micha

LackeyLad
13th June 2004, 03:45 AM
does the space between the # and include matter?

Ug
13th June 2004, 03:53 AM
Yes it does, your code should look like this:
#include <string.h>

micha
13th June 2004, 04:01 AM
Or if you use C++ Standard Library:
#include <string>
std::string my_string;
You don't need the .h extension for the C++ standard library. There is a "bridge" for the inclusion of C standard library in standard C++:

#include <cstdlib>
#include <cmath>
...

--Micha

theurge
16th June 2004, 06:29 PM
This also works:



#include <string>
using std::string;


That way you don't have the increased overhead with "using namespace std" and you don't have to scope every single string you create.