I've been playing around with Aztec-C 1.06D on the RunCPM emulator and
I've been unable to get the programs to print argv[0] (the name of the calling program). I eventually found in the Aztec-C manual an
explanation that says this is a null pointer in CP/M.
Is this the same for all CP/M versions, was it enhanced in any of the
other CCPs?
On 12/20/23 9:10 AM, Nick wrote:
I've been playing around with Aztec-C 1.06D on the RunCPM emulator and
I've been unable to get the programs to print argv[0] (the name of the
calling program). I eventually found in the Aztec-C manual an
explanation that says this is a null pointer in CP/M.
Is this the same for all CP/M versions, was it enhanced in any of the
other CCPs?
CP/M-68K gives you a pointer to "C Runtime". That might be true but I
can't recall ever checking.
The problem stems from the BDOS copying the command tail to the default
DMA buffer as part of its setup before starting the program. That does
not include the program name so it isn't available to the C runtime code
that sets up the argv array.
On Thursday 21 December 2023 at 11:08:37 UTC, Nick wrote:
On 20/12/2023 16:52, David Schultz wrote:The historic technique to provide argv[0] or equivalent, was to code it in the source code.
On 12/20/23 9:10 AM, Nick wrote:OK I've had the chance to test a bit further on CP/M 2.2 and CP/M-86
I've been playing around with Aztec-C 1.06D on the RunCPM emulator and >>>> I've been unable to get the programs to print argv[0] (the name of the >>>> calling program). I eventually found in the Aztec-C manual an
explanation that says this is a null pointer in CP/M.
Is this the same for all CP/M versions, was it enhanced in any of the
other CCPs?
CP/M-68K gives you a pointer to "C Runtime". That might be true but I
can't recall ever checking.
The problem stems from the BDOS copying the command tail to the default
DMA buffer as part of its setup before starting the program. That does
not include the program name so it isn't available to the C runtime code >>> that sets up the argv array.
with the same results so I'll find a workaround. I was playing with some
old code for Motorola 6800 series assemblers and found it works with DOS
but not under various CP/M versions. Plus it's been an interesting
learning exercise as I've never been much of a C programmer.
Whitesmiths compilers for example used _pname to store the program name, and the usage function would show this
Hi-Tech uses the prompt name passed into _getargs. By default it defines nularg i.e. "". It could easily be changed to use a user defined string similar to Whitesmiths approach
Mark
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 488 |
Nodes: | 16 (2 / 14) |
Uptime: | 05:54:58 |
Calls: | 9,663 |
Calls today: | 5 |
Files: | 13,711 |
Messages: | 6,166,933 |
Posted today: | 2 |