HP3000-L Archives

November 2003, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Walter Murray <[log in to unmask]>
Reply To:
Walter Murray <[log in to unmask]>
Date:
Fri, 14 Nov 2003 17:48:52 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
 "Peter Smithson" wrote:

[snip: description of a problem resulting from forgetting to use the
INTRINSIC phrase
in a COBOL CALL statement]

> This is what I did wrong -
> I noticed the trap info looks a bit like a stack trace and I could see
> "free" on it which I know (as a C programer) is part of the C library
> and often causes core dumps/GP's when releasing unallocated memory.
> Then I realised it must be somehow calling the fclose() function from
> the C library.  Then I realised I'd missed "intrinsic" from the call
> statement!!!  I've been developing with ACU COBOL where you don't have
> to do that - that's my excuse and I'm sticking with it.  It works now.
>
> Not sure how it found the C library though.

This is a class of problems that can be very frustrating to track down.

The entry point names for the intrinsics in XL.PUB.SYS are in uppercase.
When you use the INTRINSIC phrase in a CALL statement (thereby instructing
the compiler to look in SYSINTR.PUB.SYS to find out how the procedure
expects to be called) the compiler correctly uses uppercase for the
intrinsic name.  If you forget the INTRINSIC phrase, the compiler converts
the name to lowercase.  So Peter's program called "fclose" instead of
"FCLOSE".

Instead of calling the FCLOSE intrinsic, the program called the fclose
function of the C/iX Library, which tried to do some inappropriate things,
eventually aborting the program.

This is a potential problem with a number of the intrinsics, especially
those with names that differ only in case from functions in the C/iX
Library.  The problem can crop up in other instances, too.  For example, you
call a procedure "abc" that resides in a user XL, but you forget to specify
the XL on the RUN statement, so you end up looking for "abc" in the system
XL.  If you're lucky, it'll be an unresolved external.  If not, you'll
invoke the wrong "abc", which may do strange and wonderful things.

To catch situations where you forget to specify the INTRINSIC phrase on an
intrinsic call, resulting in this kind of confusing error, consider using
$CONTROL CALLINTRINSIC.  (You might even add it to your COBCNTL.PUB.SYS
file.)  If you try to call an intrinsic without using the INTRINSIC phrase,
it will issue a warning and then generate the correct code to call the
intrinsic.

To answer Peter's question of how it found the C library, note that most of
the C/iX Library functions exist in both relocatable form in the various
library files like LIBC.LIB.SYS, and also in executable form in XL.PUB.SYS.
As a C/iX programmer you determine which version you bind to by how you link
your program.

Walter

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2