- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: porting C to C++ on OpenVMS
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
тАО01-08-2010 07:17 AM
тАО01-08-2010 07:17 AM
porting C to C++ on OpenVMS
%CXX-E-UNDECLARED, identifier "globalvalue" is undefined
at line number 2769 in file DATA8:[DEV_SPLIT.GS.SOURCE]GS_DEF.H;287
#module rt_detail_read_sp
.^
%CXX-W-BADPPDIRKEY, unrecognized preprocessing directive
at line number 1 in file DATA8:[DEV_SPLIT.RT.USERS.RYANR]RT_DETAIL_READ_SP.C;7
status = gs_sql_error_ss(&sqlcode);
.................^
%CXX-E-UNDECLARED, identifier "gs_sql_error_ss" is undefined
at line number 90 in file DATA8:[DEV_SPLIT.RT.USERS.RYANR]RT_DETAIL_READ_SP.C;7
I was able to get rid of the above errors by compiling the external functions locally for the piece of code I was testing with.
Any help or advice would be greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 08:18 AM
тАО01-08-2010 08:18 AM
Re: porting C to C++ on OpenVMS
First, Welcome to the HP ITRC OpenVMS Forum.
I have been through this process quite a few times with various clients. I have also dealt with it a few times in moving code among VAX C, DEC C, GNU C, and DEC C++.
My experience has been that the first step is to clean up the sources. The /STANDARD=VAXC is a crutch that defers correction of a number of obsolete constructs, and they can cause more excitement when they are encountered at a later point.
Also, C++ is far more strict about defining external functions.
Often, errors will be reported due to missing declarations. Some of these will be reported at compile time, some at link time.
Most often, I turn off the back compatibility features and clean up the sources to current standard before switching to C++.
- Bob Gezelter, http://www.rlgsc.com
T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 08:49 AM
тАО01-08-2010 08:49 AM
Re: porting C to C++ on OpenVMS
Anyway, I would start with cc/stand=relaxed (relaxed ANSI C) and /warnings=enable=all. The compiler should tell you about all VMS, DEC, Compaq and/or HP extensions, you may see:
%CC-I-PRAGMAMOD, Please use the preferred "#pragma module" directive in place of the "#module" directive.
%CC-I-GLOBALEXT, A storage class of globaldef, globalref, or globalvalue is a language extension.
%CC-I-IMPLICITFUNC, In this statement, the identifier "foo" is implicitly declared as a function.
After cleanup of all the errors/warnings (or at least understanding all the warnings and the informationals) I would compile with the C++ compiler.
Depending on the C++ errors/warnings I would look up some info about the differences of C and C++. Google is your friend. As you probably know, C++ is not a superset of C.
If you do not run into differences in the language you end up with better C code: C++ requires all external functions to be declared before they can be used and it checks the interface by mangling parameter types into the function names and so making a function plus parameters unique across modules. Obviously you have to link to find all function/argument mismatches. But be aware that some external functions, for example system services, are external C functions for the C++ compiler and their interface isn't checked the same way.
But then I would recompile the sources with a C compiler. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 10:31 AM
тАО01-08-2010 10:31 AM
Re: porting C to C++ on OpenVMS
> [...]
HELP CC Language_topics Preprocessor #module
The #module directive is retained for compatibility with VAX C and
is supported only when running the HP C compiler in VAX C mode
(/STANDARD=VAXC). See also the ANSI C equivalent #pragma module
directive.
That pretty much sums it up, doesn't it?
> %CXX-E-UNDECLARED, identifier "gs_sql_error_ss" is undefined [...]
You're not using function prototypes?
> [...] the first step is to clean up the
> sources. [...]
I'm with him.
> The first step would be to try and compile
> our C code using the cxx compiler.
Why? Why not use the C compiler on the C
code (after you fix the stuff), and the C++
compiler on the C++ code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 10:50 AM
тАО01-08-2010 10:50 AM
Re: porting C to C++ on OpenVMS
- architecture
- version of C compiler
- version of C++ compiler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 01:21 PM
тАО01-08-2010 01:21 PM
Re: porting C to C++ on OpenVMS
A question for Steve - you comment on use both compilers. Is it possible to easily call the functions compiled by each compiler to the other? I may be in the wrong mindset
John - HP C Version 7.1
HP C++ V7.3-009 for OpenVMS Alpha V8.3
Actually I am researching on an alpha machine, but we just recently went over to the itanium
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 01:24 PM
тАО01-08-2010 01:24 PM
Re: porting C to C++ on OpenVMS
Yes, it is possible to have some modules in C and other modules in C++.
You will need to properly configure C++ to generate the C-compatible (non-mangled) external names. This is documented.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 02:26 PM
тАО01-08-2010 02:26 PM
Re: porting C to C++ on OpenVMS
On a small scale I was able to link some of our C code compiled with the C compiler with the c++ linker, and was able to call back and forth between functions compiled in C and C++, but both linked using the C++ compiler. It seemed the main ideas was to provide headers for the functions and use the extern "C", As Robert pointed out about name mangling.
Does anyone know of any problems doing this? This would at least allow us to slowly introduce and imporve our code base.
Are there better ways?
Is this safe to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 03:16 PM
тАО01-08-2010 03:16 PM
Re: porting C to C++ on OpenVMS
It had better be. So far as I know, that's
how the whole C run-time collection is made
available to a C++ program. Have you looked
at the C/C++ header files? 'extern "C"' is
a pretty popular construct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2010 04:37 PM
тАО01-08-2010 04:37 PM
Re: porting C to C++ on OpenVMS
I would call it a hazard, not a danger. The hazard is that functions using the C naming cannot use overloaded function names (which is what the C++ name mangling is all about).
- Bob Gezelter, http://www.rlgsc.com