www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/03/23:55:34

From: "A. Darrow" <msnsh AT freewwweb DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: GPP Compile problem
Date: Tue, 2 Nov 1999 23:21:49 -0800
Organization: Posted via Supernews, http://www.supernews.com
Lines: 89
Message-ID: <s1vhkfam24290@corp.supernews.com>
X-Complaints-To: newsabuse AT supernews DOT com
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT Delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I've run across the occassional problem in compiling with the
djgpp distribution i.e. code that will compile with say the
MS Visual C++ 6.0 environment but not with GPP, and I have
always concluded that the DJGPP header and other lib files
might be somewhat out of date. Since I am a newbie I've waited
until I am further along in hopes that the solutions to these
problems would ultimately appear.
However, my curiosity has gotten the better of me and, although
it might be a hasssle, I thought I'd pick a situation and ask
what's wrong. The code in question is listed below; a very short
& simple program.

#include "istring.cpp"
#include <iostream.h>

// Prompt with the string ps, and read a string from the input stream cin.

void Get( String & str, String ps = "Now what? " ) {
   cout << ps;
   cin >> str;
      }

// Exercise the Get() function.

      int main() {

         String s;

         Get( s );                              // use default prompt
            cout << "You entered " << s << "\n";

         Get( s, "Please enter a string: " );   // use custom prompt
            cout << "You entered " << s << "\n";
             return 0;
      }


It includes "istring.cpp" which differs in each
compiler only by a single character:

DJGPP   #include <strstream.h>
MS C++  #include <strstrea.h>

As it turns out, these two files are completely different
in each compiler distribution, although they appear to be
doing the same thing. This may be apropo of nothing.

However the GPP compile produces error messages relating to
the j variable in the following code sequence:

*******************************
const String String::Substr( unsigned int start, unsigned int nchars ) {

   String rv( nchars + 1 );         // to hold substring return value

   if ( start >= length)            // start past end of string
      return rv;

   for ( unsigned i = start, j = 0; i < length && i < start + nchars ; i++ )
      rv.store[j++] = store[i];     // copy characters into substring

   rv.store[j] = 0;                 // terminate substring
   rv.length = j;                   // set the length

   return rv;                       // return VALUE of substring
*******************************

The compiler error messages are as follows:

c:\djgpp\include\istring.cpp: in method 'const class String
   String::Substr(unsigned int, unsigned int)':
c:\djgpp\include\istring.cpp:191: name lookup of 'j' changed for new
   ANSI 'for' scoping:
c:\djgpp\include\istring.cpp:188: using obsolte binding at 'j':

I have a few questions:

1. Are some of the header, .cpp, lib files in the DJGPP distribution (v
2951) obsolete
 or out of date?

2. As an aside, since Istring.cpp has a companion, Istring.h ,what is
Istring.cpp doing
 that Istring.h cannot or is not doing?

3. What is the solution to the aforementioned problem?



- Raw text -


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