- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- C question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 07:23 AM
тАО08-12-2009 07:23 AM
C question
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 07:56 AM
тАО08-12-2009 07:56 AM
Re: C question
But I'll make a wild guess anyway. You might be passing a string by reference to lib$put_output:
lib$put_output("this won't write out");
which is not the correct argument for this routine, as you would see if you did:
$ HELP RTL LIB$ LIB$PUT_OUTPUT argument
You must set up a string descriptor and pass that instead. String descriptors are structures that contain the address and length of the string, so no assumption about zero-byte termination is necessary.
#include
auto $DESCRIPTOR(string_descrip,"This will write out.");
lib$put_output(&string_descrip);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 08:07 AM
тАО08-12-2009 08:07 AM
Re: C question
LIB$PUT_OUTPUT only takes one argument. If your want to use C style output formats you must first use sprintf() to write to a string in memory, fill in a descriptor with the address of the string and the resulting strlen() of it, and then pass the descriptor to lib$put_output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 09:19 AM
тАО08-12-2009 09:19 AM
Re: C question
> [...]
For a more timely complaint about such a
usage problem, defining __NEW_STARLET seems
to be effective:
alp $ cxx /define = (__NEW_STARLET=1) 336875.TXT
lib$put_output("Value \n ",&str_dsc);
...........................^
%CXX-E-MANYARGUMENTS, too many arguments in function call
at line number 21 in file ALP$DKA0:[SMS.ITRC]336875.TXT;1
lib$put_output("Value \n ",&a);
...........................^
%CXX-E-MANYARGUMENTS, too many arguments in function call
at line number 22 in file ALP$DKA0:[SMS.ITRC]336875.TXT;1
%CXX-I-MESSAGE, 2 errors detected in the compilation of "ALP$DKA0:[SMS.ITRC]336875.TXT;1".
Inspection of lib$routines.h shows why.
Also, as
HELP RTL_ROUTINES LIB$ LIB$PUT_OUTPUT
says,
The Put Line to SYS$OUTPUT routine
writes a record to the current
controlling output device, specified by
SYS$OUTPUT using the OpenVMS RMS $PUT
service.
I'd guess that you don't really want one
message split across multiple records.
And you're using lib$put_output() why,
exactly?
You said "C question", but around here,
alp $ cc 336875.TXT
#include
.^
%CC-F-NOINCLFILEF, Cannot find file
at line number 2 in file ALP$DKA0:[SMS.ITRC]336875.TXT;1
CXX worked better for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 10:06 AM
тАО08-12-2009 10:06 AM
Re: C question
sprintf is fine as well. If you use that, then use its Return_Values to set the length into the descriptor. "The number of characters placed in the output string, not including the final null character."
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 10:32 AM
тАО08-12-2009 10:32 AM
Re: C question
Details on creating, managing and correctly allocating and deallocating string descriptors are posted around the network. Start with reading through the OpenVMS Programming Concepts Manual (in the OpenVMS manual shelf), and the C guide in the C documentation shelf. That investment will save you time, and it'll also help improve your coding prowess. These two shelves are reachable via the URL:
http://www.hp.com/go/openvms/doc
As for the C compilation:
$ CC /WARN=ENABLE=QUESTCODE
can tend to help spot various C coding errors, and unstable code. Yes, it makes the C compiler get rather fussy about syntax and structure and such.
And here (and as a general comment), always specify and always verify the return status (condition) values from calls such as the lib$put_output routines used here. Production code is most stable when errors are consistently checked, uniformly processed, and appropriately reported. That can help identify the specific trigger for these sorts of error cases more quickly.