[Info-vax] net: device (Re: C compiler snag)

Craig A. Berry craigberry at nospam.mac.com
Fri May 21 18:47:51 EDT 2021


On 5/21/21 4:13 PM, Simon Clubley wrote:
> On 2021-05-21, Craig A. Berry <craigberry at nospam.mac.com> wrote:
>> On 5/21/21 12:42 PM, Simon Clubley wrote:
>>> There is a problem when you use net/
>>> within an include statement. The following code compiles: !!!
>>>
>>> ---------------------------------------------------------------------------
>>> $ type nettest.c
>>> #include <stdio.h>
>>> #include <net/does_not_exist.h>
>>>
>>> int main(int argc, char *argv[])
>>>           {
>>>           printf("Testing net include\n");
>>>           return 0;
>>>           }
>>> $ cc nettest.c
>>> ---------------------------------------------------------------------------
>>
>> Bug or feature I don't know, but again it seems to have nothing to do
>> with the compiler.  Opening a non-existent file on the net: device
>> returns success.  What you expect from opening a non-existent file:
>>
> 
> I'm not so sure. Based on what has been said so far, I think this
> is a compiler specific problem.
> 
> I think John Malmberg is right and that the compiler is wrongly
> looking for a device (NET:) with the name of the net/ include directory
> and using that instead of looking for a [.net] directory.

I think John M is right that something goes wrong, but it's not clear to
me how much, if any, is the compiler's fault and how much is just how
things fall out from all the different special devices.

The compiler would have to have some special handling of prefixes such
as "sys/" and "net/" in order to look things up in
sys$library:decc$rtldef.tlb because a text library is just a key lookup
and there is no nesting. But the fact that the "nl/" prefix shows the
exact same behavior as the "net/" prefix suggests that this isn't the
problem, because /usr/include/nl is not a location that needs to be
emulated in the same way that /usr/include/sys and /usr/include/net do.

>> So the compiler is just converting net/does_not_exist.h to VMS syntax
>> net:does_not_exist.h and getting a successful open but nothing happens
>> when you read from it (except EOF I guess).  The filename portion
>> doesn't matter and seems to be ignored.  As far as I can tell, the
>> behavior is identical to that of _NLA0:.
>>
> 
> That's my understanding as well. What it should be doing instead is
> looking for [.net]does_not_exist.h and then reporting an error when
> it doesn't find the file in that location.

That's the expected behavior for the source code on a Unix system, but
on VMS that's not necessarily correct behavior if "net" is a device name
or a logical name.  The logical name case can be suppressed with
DECC$DISABLE_TO_VMS_LOGNAME_TRANSLATION -- you'll probably have to do
that if you have a 'sys" logical name defined.

It does seem possible the compiler is cutting off the prefix and testing
it as a device.  That would explain why the following two tests behave
identically:

#include "net/nosuchfile.dat"
#include "nl/nosuchfile.dat"

This one is interesting:

#include "tt/nosuchfile.dat"

It will hang waiting for input from your terminal.




More information about the Info-vax mailing list