473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

what is possbole cause?

I am using SGI STL for string class. When I do following:
std::string("hi");

Comipler complains:
"myTest.C", line 10: error: namespace "std" has no member "string"
std::string str("myTest");
^

"myTest.C", line 10: error: expected a ";"
std::string str("myTest");
^

make: *** [myTest.o] Error 1

I do make depend, it clearly states:
"myTest.o: /usr/local/include/sgistl/string"

vi "/usr/local/include/sgistl/string", I can see std namespace is
defined, why does
compiler complains then?

thanks.

Oct 14 '05 #1
16 6483
#include <string>
// ?

Oct 14 '05 #2
I did

Oct 14 '05 #3
Post your code so we can help.

Oct 14 '05 #4

<we*****@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
I am using SGI STL for string class. When I do following:
std::string("hi");

Comipler complains:
"myTest.C", line 10: error: namespace "std" has no member "string"
std::string str("myTest");
^

"myTest.C", line 10: error: expected a ";"
std::string str("myTest");
^

make: *** [myTest.o] Error 1

I do make depend, it clearly states:
"myTest.o: /usr/local/include/sgistl/string"

vi "/usr/local/include/sgistl/string", I can see std namespace is
defined, why does
compiler complains then?

#include <string>

int main()
{
std::string s("hi");
return 0;
}
If this doesn't compile, I think you need
to update your compiler package.

-Mike
Oct 14 '05 #5
we*****@yahoo.com wrote:
I did


So? Does it (or, do you) know where the <string> is being pulled
from? BTW, make sure you don't put the '.h' there (sometimes some
folks just assume that <string> and <string.h> are the same thing.
They are most certainly aren't.

V
Oct 14 '05 #6
Kev
we*****@yahoo.com wrote in news:1129311810.199591.73590
@g44g2000cwa.googlegroups.com:
std::string str("myTest");


#include <string>

std::string var = "blah";

if you then need to use the string in a place that requires a char*
then use

var.c_str()

example:

std::string var = "hello";
MessageBox(NULL,var.c_str(),"Message",MB_OK | MB_ICONINFORMATION);
Right?
Oct 14 '05 #7
I think that I am mentally challenged. We are using SCO compiler which
only supports pre-std C++, but on our development platform(UnixWare
7.1), we have g++ and sgi stuff(std C++) installed.
The error I mentioned earlier, pops up when native SCO C++ compiler is
used, and I have no idea how this compiler can compile SGI stuffs.

Oct 14 '05 #8
we*****@yahoo.com wrote:
I did


Please, post a minimal piece of code that reproduces the problem. Without
seeing what you are doing, it is impossible to tell what is going wrong.
Best

Kai-Uwe Bux
Oct 14 '05 #9
this is piece of code I am trying to compile:

#include <string>

int main(int argc, char ** argv)
{
std::string str("myTest");

return 0;
}

Oct 14 '05 #10
In article <11*********************@g44g2000cwa.googlegroups. com>,
<we*****@yahoo.com> wrote:
this is piece of code I am trying to compile:

#include <string>

int main(int argc, char ** argv)
{
std::string str("myTest");

return 0;
}


It may be that you have an earlier version that doesn't used std::
so try and remove that and see what it does, and then decide if you
want that version of the compiler/lib or not.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Oct 14 '05 #11
On 14 Oct 2005 10:43:30 -0700, we*****@yahoo.com wrote:
I am using SGI STL for string class. When I do following:
std::string("hi");

Comipler complains:
"myTest.C", line 10: error: namespace "std" has no member "string"
std::string str("myTest");
^


Are you sure that the compiler is treating this as a C++ file? I know
that on Unix systems there is a difference between ".c" and ".C", but
I'm not sure if that is enough to make the compiler treat it the right
way.

--
Bob Hairgrove
No**********@Home.com
Oct 14 '05 #12
Yes, I am sure.

By peeking into the sgi file named string, I can see following:
__STL_BEGIN_NAMESPACE
:
:
__STL_END_NAMESPACE

__STL_BEGIN_NAMESPACE defined as :
# define __STL_BEGIN_NAMESPACE namespace std {

Like I mentioned before, I did "make depend", it clearly indicates that
sgi string header file is included for the test program, I just don't
get why it won't compile.

Oct 14 '05 #13

we*****@yahoo.com wrote:
Yes, I am sure.

By peeking into the sgi file named string, I can see following:
__STL_BEGIN_NAMESPACE
:
:
__STL_END_NAMESPACE

__STL_BEGIN_NAMESPACE defined as :
# define __STL_BEGIN_NAMESPACE namespace std {

Like I mentioned before, I did "make depend", it clearly indicates that
sgi string header file is included for the test program, I just don't
get why it won't compile.


Maybe "make depend" is finding a different include file than the
compiler is actually using.

-Brian

Oct 14 '05 #14
we*****@yahoo.com wrote:
Yes, I am sure.

By peeking into the sgi file named string, I can see following:
__STL_BEGIN_NAMESPACE
:
:
__STL_END_NAMESPACE

__STL_BEGIN_NAMESPACE defined as :
# define __STL_BEGIN_NAMESPACE namespace std {

Like I mentioned before, I did "make depend", it clearly indicates that
sgi string header file is included for the test program, I just don't
get why it won't compile.


Dump the preprocessor output to a file (-E with g++) and look for the
definition of std::string. Then you'll know for sure.

Cheers! --M

Oct 14 '05 #15
In article <11**********************@o13g2000cwo.googlegroups .com>,
<we*****@yahoo.com> wrote:
Yes, I am sure.

By peeking into the sgi file named string, I can see following:
__STL_BEGIN_NAMESPACE
:
:
__STL_END_NAMESPACE

__STL_BEGIN_NAMESPACE defined as :
# define __STL_BEGIN_NAMESPACE namespace std {

Like I mentioned before, I did "make depend", it clearly indicates that
sgi string header file is included for the test program, I just don't
get why it won't compile.


It may be looking at something different.
Instead, you can do two things to verify: run with -M and it will
dump out what it sees (you say gcc right?), and also use -E and
see what the #line directives and such is going on.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Oct 14 '05 #16
#include <string>
using namespace std;

....
On the other hand, change .c to .cpp.

Oct 14 '05 #17

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

Similar topics

1
by: Liza | last post by:
Hi guys, can anyone explain line number 5 to me. i don't quite understand what is going on there and why. 1 <script language="vbscript" runat="server">sub Application_OnStart 2 getcustomers...
0
by: Bill | last post by:
All I want to do is find a way to cause a vb.net / asp.net program to exceed the httpRuntime executionTimeout="xxx" value to thrown the exception, so I can do some testing. I've tried setting this...
2
by: evangeline | last post by:
We have ASP application running on IIS 5.1 and Windows 2000 server. The ASP application has few Application variables setup in global.asa. Something like this: Application.Lock()...
43
by: Mountain Bikn' Guy | last post by:
I have a situation where an app writes data of various types (primitives and objects) into a single dimensional array of objects. (This array eventually becomes a row in a data table, but that's...
2
by: active | last post by:
Set(ByVal NewSize As Drawing.Size) Me.AutoScrollMinSize = NewSize picDisplay.Size = NewSize picMarquee.Size = NewSize AdjustBitmap()
1
by: Brian Maguire | last post by:
Background Info: I have a table with a approx 2.5 million rows. The table often gets 200-300 inserts per second. We are see that the database (7.4.1 Red Hat Enterprise ED 4 way Xeon) will...
7
by: rob c | last post by:
Hi Does anyone know what triggers a "popup blocker"? I'm going to be opening some sub-windows from my main page and don't want to get caught in a blocker. Thanks Rob
9
by: Ron | last post by:
#define MAX_SIZE 512 char mybuffer; void myfunction( const char* src ) { if( src == null ) { return; } /* A core dump is occuring here */ strncpy( mybuffer, src, MAX_SIZE );
7
by: rsk | last post by:
char *i_reg_fname = "none"; -- Message posted using http://www.talkaboutprogramming.com/group/comp.lang.c/ More information at http://www.talkaboutprogramming.com/faq.html
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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 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.