"K&R" C

M

msdos6

I recently got a hold of the sources of Concurrent CP/M-86(circa 1984),
and the system builder, GENCPM is written in a K&R style C. Does GCC
support this syntax? If not, are there any K&R to ANSI converters out
there, or possibly a modern compiler supporting this syntax? Any help
is appreciated.

Thanks,

"msdos6"
 
I

Ian Collins

msdos6 said:
I recently got a hold of the sources of Concurrent CP/M-86(circa 1984),
and the system builder, GENCPM is written in a K&R style C. Does GCC
support this syntax? If not, are there any K&R to ANSI converters out
there, or possibly a modern compiler supporting this syntax? Any help
is appreciated.
Have you tried it?
 
M

msdos6

Ian said:
Have you tried it?

I don't currently have GCC on my computer because I mainly work in
FreeBASIC, and it is pointless for me to have a copy of it at this
period in time. I'll reinstall MinGW and give it a shot.
 
I

Ian Collins

msdos6 said:
I don't currently have GCC on my computer because I mainly work in
FreeBASIC, and it is pointless for me to have a copy of it at this
period in time. I'll reinstall MinGW and give it a shot.
OK, it will compile K&R style code.
 
K

Keith Thompson

msdos6 said:
I recently got a hold of the sources of Concurrent CP/M-86(circa 1984),
and the system builder, GENCPM is written in a K&R style C. Does GCC
support this syntax? If not, are there any K&R to ANSI converters out
there, or possibly a modern compiler supporting this syntax? Any help
is appreciated.

The C90 standard is mostly backward-compatible with K&R (pre-ANSI) C,
so you *probably* won't have any serious problems.

(The bad any problems you do have are likely to be subtle ones.)
 
J

jmcgill

msdos6 said:
I recently got a hold of the sources of Concurrent CP/M-86(circa 1984),
and the system builder, GENCPM is written in a K&R style C. Does GCC
support this syntax?

What characteristics of "K&R style C" does it have?

Most of these will be supported in the GNU preprocessor with
"-E -traditional".

With any CP/M-ish software I'd be more concerned about stuff relying on
8- or 16-bit wide values for various things, or architecture-specific
couplings. Last time I touched CP/M I had to deal with Z-80 asm as
well. Hopefully your software is "just plain C".
 
M

mkaras

msdos6 said:
I recently got a hold of the sources of Concurrent CP/M-86(circa 1984),
and the system builder, GENCPM is written in a K&R style C. Does GCC
support this syntax? If not, are there any K&R to ANSI converters out
there, or possibly a modern compiler supporting this syntax? Any help
is appreciated.

Thanks,

"msdos6"

Is posession of the source code legal?

Better check and make sure. Just becasue its old does not make it legal
unless its owner at one time or another released it to the public
domain.

- mkaras
 
M

msdos6

What characteristics of "K&R style C" does it have?
Most of these will be supported in the GNU preprocessor with
"-E -traditional".

With any CP/M-ish software I'd be more concerned about stuff relying on
8- or 16-bit wide values for various things, or architecture-specific
couplings. Last time I touched CP/M I had to deal with Z-80 asm as
well. Hopefully your software is "just plain C".
All the assembly is in the BDOS, XIOS, and other main parts of CP/M.
The CP/M generation tool is made out of 100% C code, so it shouldn't
really matter.
Is posession of the source code legal?

Better check and make sure. Just becasue its old does not make it legal
unless its owner at one time or another released it to the public
domain.

- mkaras

It is legal. Caldera released the source code quite a while ago. My
only real restriction with the code is that I cannot use it for
proprietary purposes.

Thank you everyone, for your help.
 
C

CBFalconer

msdos6 said:
I recently got a hold of the sources of Concurrent CP/M-86 (circa
1984), and the system builder, GENCPM is written in a K&R style C.
Does GCC support this syntax? If not, are there any K&R to ANSI
converters out there, or possibly a modern compiler supporting
this syntax? Any help is appreciated.

Where is this source?
 
J

jmcgill

mkaras said:
Is posession of the source code legal?

Can you name a jurisdiction where copyright law speaks to possession (as
opposed to duplication and distribution?)


This is certainly not true in US Federal law, any state law, nor any
European country that I know of.


Perhaps legal advice can be considered topical for comp.lang.c, but only
*correct* legal advice should be tolerated.
 
E

Elijah Cardon

Keith Thompson said:
The C90 standard is mostly backward-compatible with K&R (pre-ANSI) C,
so you *probably* won't have any serious problems.

(The bad news: any problems you do have are likely to be subtle ones.)
Given this response and if I were OP, I would strongly consider using the
original source as inspiration and writing a conforming program from
scratch, meaning with a generous ability to cut and paste. I'd bet that clc
would serve as a sounding board for it. Lack of conformance could come as
quickly as the main call, but that's certainly not the gotchas that Keith
means. EC
 
A

Andrey Tarasevich

msdos6 said:
I recently got a hold of the sources of Concurrent CP/M-86(circa 1984),
and the system builder, GENCPM is written in a K&R style C. Does GCC
support this syntax? If not, are there any K&R to ANSI converters out
there, or possibly a modern compiler supporting this syntax? Any help
is appreciated.
...

It depends on how many of K&R features are really used in the code.
Often people refer to code as being "K&R" just because it includes some
old-style function definitions. Code like this is definitely supported
by GCC.

However, if I remember correctly, the most "hardcore" (oldest?) K&R also
required all struct data members to have unique names across all structs
and allowed almost any data type of the left-hand side of '->' operator,
like

0x12345->some_field_name = 3;

Things like that are very unlikely to be supported by any modern compiler.
 
G

gw7rib

jmcgill said:
Can you name a jurisdiction where copyright law speaks to possession (as
opposed to duplication and distribution?)


This is certainly not true in US Federal law, any state law, nor any
European country that I know of.

The law in the UK mentions possession. For example, Section 23 of the
Copyright, Designs and Patents Act 1988 runs:

23 Secondary infringement: possessing or dealing with infringing copy

The copyright in a work is infringed by a person who, without the
licence of the copyright owner -
(a) possesses in the course of a business,
(b) sells or lets for hire, or offers or exposes for sale or hire,
(c) in the course of a business exhibits in public or distributes, or
(d) distributes otherwise than in the course of a business to such an
extent as to
affect prejudicially the owner of the copyright,
an article which is, and which he knows or has reason to believe is, an
infringing copy of
the work.
Perhaps legal advice can be considered topical for comp.lang.c, but only
*correct* legal advice should be tolerated.

Possibly best to keep legal advice off clc altogether...
 
A

Arthur J. O'Dwyer

It depends on how many of K&R features are really used in the code.
Often people refer to code as being "K&R" just because it includes some
old-style function definitions. Code like this is definitely supported
by GCC.

However, if I remember correctly, the most "hardcore" (oldest?) K&R also
required all struct data members to have unique names across all structs
and allowed almost any data type of the left-hand side of '->' operator,
like

0x12345->some_field_name = 3;

Things like that are very unlikely to be supported by any modern compiler.

FWIW, I just tested on Green Hills' C compiler, with the -k+r option,
and it does support the 0x12345->some_field_name syntax. (It allows
field names to be duplicated, too, as long as any ambiguous access
uses a field name all of whose appearances are at the same offset.)

I agree that any free-or-cheap compiler that the OP is likely to
have, is very unlikely to support that syntax. But /someone/ is
always willing to pay a lot for backwards compatibility. :)

-Arthur,
conflict of interest
 
M

msdos6

It seems that OpenWatcom will compile it correctly as long as a fix
some type mismatches, and remove the CP/M dependant code.

As for the legality of this source code, there are 2 liscences for CP/M
which I have considered:
1) If you search for the CP/M license, you will see the original
caldera license. This license I believe is no longer in effect. It
states that I may use the source code for non-commercial use.

2) If you go onto cpm.z80.de, you will see the reissued license posted
on the site by Lineo. It's a bit sparse, but it seems to say the same
thing.
 
E

Elijah Cardon

The law in the UK mentions possession. For example, Section 23 of the
Copyright, Designs and Patents Act 1988 runs:

23 Secondary infringement: possessing or dealing with infringing copy

The copyright in a work is infringed by a person who, without the
licence of the copyright owner -
(a) possesses in the course of a business,
(b) sells or lets for hire, or offers or exposes for sale or hire,
(c) in the course of a business exhibits in public or distributes, or
(d) distributes otherwise than in the course of a business to such an
extent as to
affect prejudicially the owner of the copyright,
an article which is, and which he knows or has reason to believe is, an
infringing copy of
the work.


Possibly best to keep legal advice off clc altogether...
That's not advice; it's a statute. I certainly agree that it is possibly
best to keep legal advice off clc. EC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top