[comp.sys.mac.programmer] _CType Link Error

bernied@yoyodyne.ncsa.uiuc.edu (07/10/90)

	I am having a problem linking with MPW.  When my programs use the
"is" (e.g. isalpha, iscntrl, isdigit, isupper, etc) functions from the file
<CType.h> the linker complains:
	### Link: Error: Undefined entry, name: (Error 28) "_CType"

I have linked the particular program with every C library I could find, but to
no avail.

	I think this has something to do with the 3.1 (3.0?) C libraries, or
with the new C++ libraries.  I was not having these problems before I installed
one of these packages (I can't remember which).

Environment:
	MPW Shell 3.1
	C 3.1
	Libraries 3.0
	CLibraries 3.0
	CPlusLibraries 3.1B1

_CType as defined in <CType.h>:
	extern char 	 _CType[];

Does any one have a clue as to what is going on?  Is there a fix for this
problem?  Is there a problem?

Bernhard Damberger
bernied@yoyodyne.ncsa.uiuc.edu

mneerach@inf.ethz.ch (Matthias Ulrich Neeracher) (07/10/90)

In article <900041@yoyodyne> bernied@yoyodyne.ncsa.uiuc.edu writes:
>	I am having a problem linking with MPW.  When my programs use the
>"is" (e.g. isalpha, iscntrl, isdigit, isupper, etc) functions from the file
><CType.h> the linker complains:
>[...]
>_CType as defined in <CType.h>:
>	extern char 	 _CType[];
>
>Does any one have a clue as to what is going on?  Is there a fix for this
>problem?  Is there a problem?

I ran into this last weekend. The problem seems to be that somebody seems to
rename _CType in every release so if your version of the header and StdCLib.o
don't match, you get problems. The name used to be _ctype, I think, in my
version of StdCLib.o, it is _p_CType and in the header it is _CType.

I found two workarounds:

1) DON'T USE THIS ANY MORE ! DOESN'T WORK ANY MORE !
   At the first transition _ctype -> _p_CType, it was possible to just
   include -ma _ctype=_P_CType in every link. This doesn't work now, because
   the aforementioned somebody also changed some of the constants, so you
   get wrong answers with this approach.

2) The easy way out:
   Remove from ...:CIncludes:CType.h all the macros that have also function 
   prototypes defined. Recompile your C sources. Your program will loose
   efficiency, but so what.

I think it's probably not Apple who is responsible for these constant changes,
but the final touches put on the ANSI standard. 

Standard libraries aren't.

Matthias

bhd20867@uxa.cso.uiuc.edu (07/11/90)

	I was able to figure out what was wrong the next day.  I compared the
<CType.h> file on my hard drive with the version that is released on the 3.0
C disk.  They were different.  The <CType.h> file installed on my hard drive
was the C++ version.  Here are the differences.
	C 3.0 CType.h:		extern char 	 _ctype[];
	C++ 3.1B1 CType.h:	extern char 	 _CType[];

	It comes down to the fact that I did not install the new C libraries
that come with the Beta C++ distribution.  But I did install the Beta C++
header files, creating a discrepency.  Well time to install new C libraries.

Thanks to Landon Dyer (landon@apple.com) and Tom Dowdy (dowdy@apple.com)
for pointing out my header/library discrepency.

bernied@yoyodyne.ncsa.uiuc.edu
Bernhard Damberger