Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!beta!unm-la!unmvax!nmtsun!hydrovax From: hydrovax@nmtsun.nmt.edu (M. Warner Losh) Newsgroups: comp.lang.c Subject: Re: C on VMS Summary: Here's how. Message-ID: <1252@nmtsun.nmt.edu> Date: 23 Jan 88 19:15:51 GMT References: <11421@brl-adm.ARPA> Organization: NMT Hydrology program Lines: 63 In article <11421@brl-adm.ARPA>, hsw@TYCHO.arpa (Howard Weiss) writes: > I am a UNIX C programmer and have just recently been playing around with This was your first mistake :-). > a VMS system and a C Compiler running on it. Unfortunately, I don't > have any documentation of the VMS C compiler and I'm having trouble > doing something that seems quite natural to do - command line > argument processing. I am able to compile and link programs so > that I have a resulting file (foo.exe) which I can then run using > the VMS 'run' command (r foo). The problem I have it how do I pass > arguments into the program (i.e., UNIX-style, foo -w). If I give > any args on the VMS 'run' command line, the system complains about > too many parameters. In addition, touching argv in the C program > either gives bogus information or causes the program to bomb. > OK, here's how. The program that you are writing needn't be changed (if you are trying to access the command line args the way that UNIX systems usually do). You need to do a little set up in DCL. First you need to define a symbol (say foo) as follows: $ foo :== $disk:[dir]foo This tells VMS that FOO is a foriegn command and to pass the rest of the line to the process unscathed. Well, almost unscathed. It converts the whole thing that isn't contained in quotes to UPPER CASE. The 'C' compiler, not to be outdone, converts them back to lower case. So, this makes it inconvient to have -f and -F mean different things. If you want to pass mixed case you need to inclose the operands in quotes as follows: $ foo "-F" file Would set argv[1] to "-F", like you want (The quotes are for clarity in this line, but not in the command, your program doesn't see them). A warning about argv[0]. It is the complete file specification that the program was run as (that is it ignores what you type on the command line.) So if you had $ foo :== disk:[dir]foo $ bar :== disk:[dir]foo Your program couldn't tell the difference between foo xxx and bar xxx. This is the way it works in VAX C 2.2. They may have changed it for 2.3. I hope that this helps some. Also note: If you are using 2.2 (but not 2.3) they exit(0) produces strange results. This has been fixed in 2.3. To find the compiler version, do something like: $ CC/LIST foo $ TYPE FOO.LIS and look at the top of each page. The compiler version is listed there. You may want to do this for a SMALL 'C' program first (like hello world). -- bitnet: lush@nmt.csnet M. Warner Losh csnet: warner%hydrovax@nmtsun uucp: ...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!warner%hydrovax ...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!hydrovax Warning: Hydrovax is both a machine, and an account, so be careful.