delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/09/10:16:40

From: Charles Krug <charles AT mail DOT pentek DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: c++ std::string--npos seems to be broken
Date: Fri, 09 Oct 1998 09:32:23 -0400
Organization: Pentek Corporation
Lines: 36
Message-ID: <361E1066.75DD4CE7@mail.pentek.com>
NNTP-Posting-Host: mail.pentek.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.04 [en] (WinNT; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

<HTML>
Hello List!,

<P>I'm not sure if this is a problem specific to djgpp or whether this
applies to all versions of gcc2.8.1.

<P>I built something like this:<TT></TT>

<P><TT>#include &lt;stdlib> // workaround for the c++ headers</TT>
<BR><TT>#include &lt;string> // std string classes</TT>
<BR><TT>#include &lt;iostream></TT><TT></TT>

<P><TT>int main()</TT>
<BR><TT>{</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; string hexes = "0123456789abcdef";</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; string fred "12345";</TT>
<BR><BR>
<TT>&nbsp;&nbsp;&nbsp; if (hexes.find(fred) == npos) // complains here
that npos is undefined</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "I can't
find it\n";</TT><TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp; return 0;</TT>
<BR><TT>}</TT><TT></TT>

<P>I'm not sure if I'm missing some kind of scope resolution or what.&nbsp;
npos is defined, either in string or in bastring, I forget which, but it
IS defined as part of string, in a file that I've included.&nbsp; It's
easy enough to use "&lt; 0" instead of npos, but I'd rather do almost anything
than try to feed the compiler magic numbers just to make it happy

<P>Suggestions are welcome
<BR>&nbsp;

<P>Charles</HTML>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019