[comp.lang.c] Help me translate into C

davidsen@steinmetz.ge.com (William E. Davidsen Jr) (07/08/88)

  I recently got a really nice bunch of software written in a C-like
language. It's some proprietary version like Turbo-C, or something. I
need someone to explain what some of the proprietary constructs do.

  First "pascal." On old versions of VMS this meant it was expected to
call a Pascal procedure, however all procedures are written in almost-C.
Second "cdecl." I know it was in dpANS briefly, but I don't see it in my
old copy and the new one hasn't arrived yet.

  A macro "SEEK_SET" as the third argument of lseek. From context it
appears to be a macro with a conditional evaluation, since the values 0,
1, or 2 don't make sense in all places. Anyone have a clue?

  It also uses a few things like O_BINARY which means untranslated on
systems having funny filetypes like DOS and VMS.

  If anyone has a clue I'd really appreciate it. I have enough trouble
with real C, and haven't bothered to learn all the versions which only
run on machines from a single vendor or one a single OS.

  Mail or post, if I get any info or find out the answers here I'll post
the results.
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me

gwyn@brl-smoke.ARPA (Doug Gwyn ) (07/08/88)

In article <11475@steinmetz.ge.com> davidsen@crdos1.UUCP (bill davidsen) writes:
>First "pascal."

That indicates that a Pascal-compatible calling sequence is to be used
for the function so labeled.  This is normally needed only when using
externally-provided library routines compiled under Pascal.  If your
version of such routines have C-compatible interfaces, remove the
"pascal" keywords or #define them as nothing.

>Second "cdecl."

That indicates that a C-compatible calling sequence is to be used for
the function so labeled.  Just drop the "cdecl" keywords or #define
them as nothing.

>I know it [cdecl] was in dpANS briefly, ...

I don't think so; certainly not while I've been on the committee.
It would make no sense to include it in the C Standard, since it
would have to be a no-op.

>  A macro "SEEK_SET" as the third argument of lseek.

On any UNIX-compatible system this has to be defined as 0.

>  It also uses a few things like O_BINARY which means untranslated on
>systems having funny filetypes like DOS and VMS.

The ANSI C equivalent would be the "b" mode suffix for the various
standard I/O routines fopen(), freopen().  On any UNIX-compatible
system there is no distinction between text and binary file modes,
so O_BINARY can be removed (or #defined as 0).

tneff@dasys1.UUCP (Tom Neff) (07/15/88)

In article <11475@steinmetz.ge.com> davidsen@crdos1.UUCP (bill davidsen) writes:
>  [Turbo C?] also uses a few things like O_BINARY which means untranslated on
>systems having funny filetypes like DOS and VMS.

Doug Gwyn answered Bill's questions in detail.  I just want to point out
that MS-DOS has no "funny filetypes."  All typing is by convention only,
everything is really just a string of bytes.  The O_BINARY flag controls
the way the DOS "C" runtime behaves on things like end-of-file (soft via
^Z or hard via filesize) and newline (swallow ^M's or not).

-- 
Tom Neff			UUCP: ...!cmcl2!phri!dasys1!tneff
	"None of your toys	CIS: 76556,2536	       MCI: TNEFF
	 will function..."	GEnie: TOMNEFF	       BIX: t.neff (no kidding)