Subject: [FreeVMS] Re: Subroutine interface definitions
From: Edward Brocklesby (ejb@goth.net)
Date: Sun Dec 28 2003 - 13:21:48 CET
On Sun, 2003-12-28 at 12:03, Roar Thronæs wrote:
> > I would rather see the C compiler generating automatically the
> > descriptor, as it works for other languages. In PL/I for example I can
> > write:
>
> How would the compiler know the difference between when to pass
> 'log' as null terminated string and as a string descriptor?
It would be part of the function prototype. Something like:
void f( int, __descriptor );
f( 10, "foo" );
$DESCRIPTOR( dfoo, "foo" );
f( 10, &dfoo );
I can't remember how PL/I does this off hand, but it's something along
those lines.
The only problem I can think of is how the compiler would know which
types (structs) are valid to be passed to a __descriptor function.
Maybe an __attribute__ -- but now this is becoming a lot of work for
relatively small gain (and something that even VMS itself doesn't do).
>
> > sts$value = cli$present('log');
> >
> > With some of the C99 literal extensions, it *may* not even be required
>
> How do you use C99 literals for this?
I can't remember off hand whether C99 allows struct literals. If it
did, a #define for the function may work - but then, you wouldn't be
able to pass a normal descriptor, so it might be better to modify the
compiler. Alternatively you could pass an array literal which
corresponds to the descriptor layout, but that's going to be error-prone
and a bad idea.
> Can we have a macro that does something like the Bliss %ASCID?
>
> Would rather use cli$present(%ASCID'log') than cli$present('log'),
> since it makes it clear that null termination is not used.
What does %ASCID do - create a temporary descriptor? This would be
easy enough to do in C++ (modulo taking the address of a temporary), but
in C I can't think of an obvious method.
f( __descriptor("foo") ); // perhaps?
I don't think could be a macro, though. It would have to be a compiler
change.
> Is there a particular problem in C of using
> $DESCRIPTOR(str,"xyz");
> or
> struct dsc$descriptor d;
> d.dsc$a_pointer=...;
> d.dsc$w_length=...;
> ?
When making a lot of calls to routines which take a descriptor, I've
found it messy to have to pre-define a large number of descriptors.
It's not a serious problem, though - I was only suggesting a different
method if it were to be done.
Regards,
Edward.
-- Liste de diffusion FreeVMS Pour se désinscrire : mailto:freevms-request@ml.free.fr?subject=unsubscribe
This archive was generated by hypermail 2b25 : Sun Dec 28 2003 - 13:21:19 CET