delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/27/03:49:01

From: garyt AT pacific DOT net DOT sg (Gary Tan)
Newsgroups: comp.lang.c++;,comp.os.msdos.djgpp
Subject: Help, DJGPP(dos) from CC (unix)
Date: Wed, 23 Jul 1997 13:52:50 GMT
Organization: Centre for Computer Studies, Ngee Ann Polytechnic - Singapore
Lines: 111
Message-ID: <33d6032c.4065480@news.pacific.net.sg>
Reply-To: garyt AT pacific DOT net DOT sg
NNTP-Posting-Host: dyn118ppp251.pacific.net.sg
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi all,
	I've got a minor problem.

I try to run a compile/link a simple program and I get an error.

Listing of C++ program "t.c"
-------------------------------------------

#include <iostream.h>
#include "chiarray.h"
#include "chistrng.h"

main()
{
 String oFirstName("Adam");
 String oSurName("Zecheus");
 cout << "First Name is " << oFirstName << 
         " Surname is "    << oSurName << endl;

 Array<String> ooaName(0,1);
 ooaName[0] = oFirstName;
 ooaName[1] = oSurName;
 if (ooaName[0] < ooaName[1])
    cout << "Adam is less than Zecheus" << endl;
 else
    cout << "Zecheus is less than Adam" << endl;
}

output: 
-----------

t.c: In function 'int main()':
t.c: 7: 'String' undeclared (first use ...)
etc...

-------------------------------------------------------------------------

Part of header file ChiStrng.h:
----------------------------------------------

class Chi_String
/* PURPOSE:       A string class
*/
{
public:
   enum {NPOS = INT_MAX}; // maximum number of positions in string

   Chi_String();                       // constructs an empty string
   Chi_String(const char s[]);
   Chi_String(char ch);

   char& operator[](int i);
   void set(int i, char ch);

   void insert(int at, const Chi_String& s);
   void insert(int at, const char s[]);
   void insert(int at, char ch);
   void insert_field(int, const Chi_String&);


} etc...


Anyway the source works on the UNIX CC program, using a makefile.

Listing of Makefile
----------------------------

#makefile
CHIFLAG = -I/home/student8/common/Headers -lchi -DCHI_RENAME 

OBJECT = 

#Note: compile any files with .C extension and produce the respective
object 
#      files 
#Note: -g and -c are compilation flags
.C.o:
	CC -g -c $< 

#Produce an executable program: 
#Compile .C file, link with library libchi.a
#Header files stored in /home/student8/common/Headers

tryArrStr:        tryArrStr.C
	CC -g $(CHIFLAG) tryArrStr.C -o $@

tryarr~1:         tryarr~1.c
  	CC -g $(CHIFLAG) tryArr~1.C -o $@

------------------------------------------------------------------------------------------------

I suppose the makefile renames the chi_String to String
since it was declared as a chi_String in the header file.

is there a way to overcome this???

I have tried renaming all the header files from the chilib (Cay
Horstmann's Library) to remove the Chi_*, however it doesn't work. I
am trying to bring my school assignments home, but am stumped by this
horrendous error. Can someone pls help me??? 

pls CC to me as well.

regards,


Gary Tan
garytan AT pobox DOT org DOT sg
garyt AT pacific DOT net DOT sg
s5545301 AT np DOT ac DOT sg

- Raw text -


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