Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / February 2006



Tip: Looking for answers? Try searching our database.

link warning: isdigit() multiply-defined

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bill - 08 Feb 2006 07:43 GMT
Pretty quiet in here...shame really.

Anyway, I'm getting this link warning:

============================
Link Warning : ignored 'isdigit' (code) in MSL_C_Mach-O_D.lib
Previously defined in my_file.c

Link Warning : ignored 'isdigit' (code) in libSystem.B.dylib
Previously defined in my_file.c
============================

However, isdigit() is most definitely *not* defined in my_file.c. My
file merely uses isdigit(), once, in code like this:

if ( isdigit( someChar ) )
    {
    // do something
    }

If I remove the call, say, like this:

if ( false  /*isdigit( someChar )*/ )
    {
    // do something
    }

the link warning goes away.

My System Access Paths are set like this:

{Compiler}MSL/MSL_C        (recursive)
{Compiler}MacOS X Support    (recursive)
{OS X Volume}usr/include
{OS X Volume}usr/lib
{OS X Volume}System/Library/Frameworks  (marked with framework "f" symbol)

This is a Mach-O Carbon app in CW 10. The app compiles fine in XCode
2.2. But debugging on a Powerbook is so painfully slow in XCode that I
wanted to try using the CW debugger on it, so I back ported the thing
to CW.

The app builds fine in XCode. It builds in CW with no errors and no
warnings - except for this. The same bit of code pasted into a CW
Mach-O sample app links fine, and I've triple-checked that my project
settings match the working sample.

It's been some years since I used CW regularly, but there was a time
when I lived in it. After trying to fix this off and on over several
days, though, I have to admit to being stumped.
Ben Artin - 08 Feb 2006 12:43 GMT
> Pretty quiet in here...shame really.
>
[quoted text clipped - 7 lines]
> Previously defined in my_file.c
> ============================

Ignore it. It makes it impossible to use MallocDebug with your app, but
otherwise it's harmless AFAIK.

Ben

Signature

If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>

bill - 08 Feb 2006 16:01 GMT
> Ignore it. It makes it impossible to use MallocDebug with your app, but
> otherwise it's harmless AFAIK

Well, actually, no....

In my first post, I neglected to mention (sorry) that that the app
crashes on the call to isdigit() with an access fault violation (when
run in CW debugger) or with

EXC_BAD_ACCESS (0x0001)
KERN_PROTECTION_FAILURE (0x0002) at 0x00000008.

when run standalone.

I think it boils down to this: the linker thinks isdigit() is alreayd
defined in my_file.c and so doesn't link in an implementation from
either MSL or BSD. Thus when the function is called, the app jumps off
into the weeds.

The question is, why does it think isdigit is defined in one of my files?

Anyway (besides having a no-warnings policy here at work) I'm not ever
going to be satisfied not knowing why one project gets that warning and
another one doesn't...
Ben Artin - 09 Feb 2006 00:26 GMT
> > Ignore it. It makes it impossible to use MallocDebug with your app, but
> > otherwise it's harmless AFAIK
[quoted text clipped - 14 lines]
> either MSL or BSD. Thus when the function is called, the app jumps off
> into the weeds.

I do not believe your explanation is correct. You can easily verify this by
checking whether the PC is zero when you crash, or whether the PC is valid and
you are trying to dereference 0x00000001 through some other register.

> The question is, why does it think isdigit is defined in one of my files?

Because the function is marked inline in CW headers.

> Anyway (besides having a no-warnings policy here at work)

It is completely impossible to use MW standard library on Mac OS X if you have a
no-linker-warnings policy. Sorry.

> I'm not ever going to be satisfied not knowing why one project gets that
> warning and another one doesn't...

My guess that one of the following is true:

a) Other project doesn't use isdigit, and hence it's not inlined
b) Other project doesn't use MW standard library (uses Apple's instead)
c) Other project has inlining turned off
d) Phase of the moon :-)

Ben

Signature

If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>

bill - 09 Feb 2006 06:53 GMT
> I do not believe your explanation is correct.

Maybe so, but the exact mechanism of the crash is irrelevant.  Calling
a nonexistent function is going to crash one way or another. That isn't
the problem. The problem is that the code for isdigit() and friends
isn't being linked into the app.

> Because the function is marked inline in CW headers.

Exactly how would that make the linker think that a *call* to isdigit()
is the *definition* of isdigit()?

> It is completely impossible to use MW standard library on Mac OS X if
> you have a no-linker-warnings policy. Sorry.

Actually, a few benign warnings wouldn't matter, since all I want is is
the convenience of using the CW debugger for a brief time. But you say
this as if it were a widely-known fact. Where may I find documentation
of this? If MSL always causes linker warnings on OS X, I'd like to know
exactly which ones, so as to which are benign and which aren't.
Clearly, the ones I'm experiencing are not.

My guess that one of the following is true:

> a) Other project doesn't use isdigit, and hence it's not inlined

Um, as originally stated, I *added* isdigit() to the other test project
(built from stationery). It runs fine and has no warnings.

> b) Other project doesn't use MW standard library (uses Apple's instead)

Nope. The test project was created from Mach-O stationery,  and
MSL_ALL_Mach-O_D.lib is in the project.

> c) Other project has inlining turned off

Inlining is OFF in both projects. Strike three.

> d) Phase of the moon :-)

Brilliant. Thanks.
bill - 09 Feb 2006 07:08 GMT
For anyone who might run into this problem, I was able to solve it by
bailing on MSL and using BSD.

The Access Paths which worked are:

{Compiler}MacOS X Support/Headers/(wchar_t Support fix)
{OS X Volume}usr/include
{OS X Volume}usr/lib
{Compiler}MacOS X Support    (recursive)
{OS X Volume}System/Library/Frameworks  (marked with framework "f" symbol)

The Mach-O project now compiles and links with no errors or warnings
and runs fine.

If anyone reads this and has factual information on how to use
isdigit() and other ctype functions with CW 10 and MSL without getting
link errors, I'd be happy to learn it. Not really interested in SWAGs
involving stumpwater at midnight under a full moon, etc.
Ben Artin - 09 Feb 2006 08:53 GMT
> > I do not believe your explanation is correct.
>
> Maybe so, but the exact mechanism of the crash is irrelevant.  Calling
> a nonexistent function is going to crash one way or another. That isn't
> the problem. The problem is that the code for isdigit() and friends
> isn't being linked into the app.

I believe you are wrong about the function being non-existed, and if you take
the time to check I suspect you will find out that isdigit exists and is
actually crashing.

> > Because the function is marked inline in CW headers.
>
> Exactly how would that make the linker think that a *call* to isdigit()
> is the *definition* of isdigit()?

You are confused about what I am saying. Since isdigit is inline, the compiler
generates a copy of the code for isdigit() while compiling your source code, and
that copy of code for isdigit() is reported as being "in yourfile.c". The other
copy is in the system framework, and linker subsequently gives you a warning for
duplicate definitions.

> > It is completely impossible to use MW standard library on Mac OS X if
> > you have a no-linker-warnings policy. Sorry.
[quoted text clipped - 5 lines]
> exactly which ones, so as to which are benign and which aren't.
> Clearly, the ones I'm experiencing are not.

The warnings themselves are benign here. All that the warning says is that the
compiler included isdigit() in the object code generated for your source file
(as expected for an inline function) and that isdigit() is also present in the
system framework. This is not a cause for concern in an of itself. Something
else is going on that is causing your crash.

The fact that MSL gives you duplicate symbol warnings is, indeed, well-known, by
which I mean "it's been bitched about on Usenet more than once". I don't mean to
imply that you should have known this before asking your question -- previous
complaints have involved any number of dozens of other inline functions in MSL.

> My guess that one of the following is true:
> >
[quoted text clipped - 15 lines]
>
> Brilliant. Thanks.

Is isdigit() in the crashing project being called before main()? MSL isdigit()
depends on a lookup table that I believe is stored in thread-local data; if said
thread local data is uninitialized, or if the attempt to initialize it failed,
you may end up deferencing page 0 from inside isdigit() and crashing.

Ben

Signature

If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.