<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: porting C to C++ on OpenVMS in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560933#M43365</link>
    <description>thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;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.  &lt;BR /&gt;&lt;BR /&gt;Does anyone know of any problems doing this? This would at least allow us to slowly introduce and imporve our code base.&lt;BR /&gt;&lt;BR /&gt;Are there better ways?&lt;BR /&gt;&lt;BR /&gt;Is this safe to do?</description>
    <pubDate>Fri, 08 Jan 2010 22:26:38 GMT</pubDate>
    <dc:creator>Ryan Rogalla</dc:creator>
    <dc:date>2010-01-08T22:26:38Z</dc:date>
    <item>
      <title>porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560926#M43358</link>
      <description>The team I work with has been looking at cleaning up our company's rather large business application written in C.  One of the things we are looking at is starting to use C++.  The first step would be to try and compile our C code using the cxx compiler.  We have been running into a lot of errors.  Has any one else went through this before?  I knoticed one of the settings on the cc compiler is /STANDARD=VAXC, which I am sure was used during the migration over to the alphas.  Is there anything similar for the cxx compiler?  Some of the main errrors I am seeing is &lt;BR /&gt;&lt;BR /&gt;%CXX-E-UNDECLARED, identifier "globalvalue" is undefined&lt;BR /&gt;at line number 2769 in file DATA8:[DEV_SPLIT.GS.SOURCE]GS_DEF.H;287&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#module rt_detail_read_sp&lt;BR /&gt;.^&lt;BR /&gt;%CXX-W-BADPPDIRKEY, unrecognized preprocessing directive&lt;BR /&gt;at line number 1 in file DATA8:[DEV_SPLIT.RT.USERS.RYANR]RT_DETAIL_READ_SP.C;7&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;        status = gs_sql_error_ss(&amp;amp;sqlcode);&lt;BR /&gt;.................^&lt;BR /&gt;%CXX-E-UNDECLARED, identifier "gs_sql_error_ss" is undefined&lt;BR /&gt;at line number 90 in file DATA8:[DEV_SPLIT.RT.USERS.RYANR]RT_DETAIL_READ_SP.C;7&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Any help or advice would be greatly appreciated.</description>
      <pubDate>Fri, 08 Jan 2010 15:17:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560926#M43358</guid>
      <dc:creator>Ryan Rogalla</dc:creator>
      <dc:date>2010-01-08T15:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560927#M43359</link>
      <description>Ryan,&lt;BR /&gt;&lt;BR /&gt;First, Welcome to the HP ITRC OpenVMS Forum.&lt;BR /&gt;&lt;BR /&gt;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++.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Also, C++ is far more strict about defining external functions.&lt;BR /&gt;&lt;BR /&gt;Often, errors will be reported due to missing declarations. Some of these will be reported at compile time, some at link time.&lt;BR /&gt;&lt;BR /&gt;Most often, I turn off the back compatibility features and clean up the sources to current standard before switching to C++.&lt;BR /&gt;&lt;BR /&gt;- Bob Gezelter, &lt;A href="http://www.rlgsc.com" target="_blank"&gt;http://www.rlgsc.com&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;T</description>
      <pubDate>Fri, 08 Jan 2010 16:18:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560927#M43359</guid>
      <dc:creator>Robert Gezelter</dc:creator>
      <dc:date>2010-01-08T16:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560928#M43360</link>
      <description>I saw it in another reply: "Don't! ?! :-)". You may have some good reasons to convert the code and you are probably aware, that even if you compile with C++, this is still C code.&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;&lt;BR /&gt;%CC-I-PRAGMAMOD, Please use the preferred "#pragma module" directive in place of the "#module" directive.&lt;BR /&gt;&lt;BR /&gt;%CC-I-GLOBALEXT, A storage class of globaldef, globalref, or globalvalue is a language extension.&lt;BR /&gt;&lt;BR /&gt;%CC-I-IMPLICITFUNC, In this statement, the identifier "foo" is implicitly declared as a function.&lt;BR /&gt;&lt;BR /&gt;After cleanup of all the errors/warnings (or at least understanding all the warnings and the informationals) I would compile with the C++ compiler.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;But then I would recompile the sources with a C compiler. :-)</description>
      <pubDate>Fri, 08 Jan 2010 16:49:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560928#M43360</guid>
      <dc:creator>H.Becker</dc:creator>
      <dc:date>2010-01-08T16:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560929#M43361</link>
      <description>&lt;!--!*#--&gt;&amp;gt; #module rt_detail_read_sp&lt;BR /&gt;&amp;gt; [...]&lt;BR /&gt;&lt;BR /&gt;HELP CC Language_topics Preprocessor #module&lt;BR /&gt;&lt;BR /&gt;The #module directive is retained for compatibility with VAX C and&lt;BR /&gt;is supported only when running the HP C compiler in VAX C mode&lt;BR /&gt;(/STANDARD=VAXC).  See also the ANSI C equivalent #pragma module&lt;BR /&gt;directive.&lt;BR /&gt;&lt;BR /&gt;That pretty much sums it up, doesn't it?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt; %CXX-E-UNDECLARED, identifier "gs_sql_error_ss" is undefined [...]&lt;BR /&gt;&lt;BR /&gt;You're not using function prototypes?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] the first step is to clean up the&lt;BR /&gt;&amp;gt; sources. [...]&lt;BR /&gt;&lt;BR /&gt;I'm with him.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt; The first step would be to try and compile&lt;BR /&gt;&amp;gt; our C code using the cxx compiler.&lt;BR /&gt;&lt;BR /&gt;Why?  Why not use the C compiler on the C&lt;BR /&gt;code (after you fix the stuff), and the C++&lt;BR /&gt;compiler on the C++ code?</description>
      <pubDate>Fri, 08 Jan 2010 18:31:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560929#M43361</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-01-08T18:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560930#M43362</link>
      <description>Can you tell us the:&lt;BR /&gt;&lt;BR /&gt;- architecture&lt;BR /&gt;- version of C compiler&lt;BR /&gt;- version of C++ compiler</description>
      <pubDate>Fri, 08 Jan 2010 18:50:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560930#M43362</guid>
      <dc:creator>John Reagan</dc:creator>
      <dc:date>2010-01-08T18:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560931#M43363</link>
      <description>Thanks for the suggestions so far.  I realize this could take some effert.  Right now we are in the research stage of trying to improve our application (architecture, coding standards, etc).  Of coarse finding time is another issue with the continual projects coming through (same old story).  We are basically looking at options, and one is to try and make small incremental improvements and try and propagate them through the system.  For some of the things we have discussed it would make life easier to use C++, and gradualy move it in to our code base.  I am just trying to get a feel for the effet.&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;John - HP C Version 7.1&lt;BR /&gt;HP C++ V7.3-009 for OpenVMS Alpha V8.3&lt;BR /&gt;&lt;BR /&gt;Actually I am researching on an alpha machine, but we just recently went over to the itanium&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Jan 2010 21:21:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560931#M43363</guid>
      <dc:creator>Ryan Rogalla</dc:creator>
      <dc:date>2010-01-08T21:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560932#M43364</link>
      <description>Ryan,&lt;BR /&gt;&lt;BR /&gt;Yes, it is possible to have some modules in C and other modules in C++. &lt;BR /&gt;&lt;BR /&gt;You will need to properly configure C++ to generate the C-compatible (non-mangled) external names. This is documented.&lt;BR /&gt;&lt;BR /&gt;- Bob Gezelter, &lt;A href="http://www.rlgsc.com" target="_blank"&gt;http://www.rlgsc.com&lt;/A&gt;</description>
      <pubDate>Fri, 08 Jan 2010 21:24:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560932#M43364</guid>
      <dc:creator>Robert Gezelter</dc:creator>
      <dc:date>2010-01-08T21:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560933#M43365</link>
      <description>thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;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.  &lt;BR /&gt;&lt;BR /&gt;Does anyone know of any problems doing this? This would at least allow us to slowly introduce and imporve our code base.&lt;BR /&gt;&lt;BR /&gt;Are there better ways?&lt;BR /&gt;&lt;BR /&gt;Is this safe to do?</description>
      <pubDate>Fri, 08 Jan 2010 22:26:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560933#M43365</guid>
      <dc:creator>Ryan Rogalla</dc:creator>
      <dc:date>2010-01-08T22:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560934#M43366</link>
      <description>&lt;!--!*#--&gt;&amp;gt; Is this safe to do?&lt;BR /&gt;&lt;BR /&gt;It had better be.  So far as I know, that's&lt;BR /&gt;how the whole C run-time collection is made&lt;BR /&gt;available to a C++ program.  Have you looked&lt;BR /&gt;at the C/C++ header files?  'extern "C"' is&lt;BR /&gt;a pretty popular construct.</description>
      <pubDate>Fri, 08 Jan 2010 23:16:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560934#M43366</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-01-08T23:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560935#M43367</link>
      <description>Ryan,&lt;BR /&gt;&lt;BR /&gt;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). &lt;BR /&gt;&lt;BR /&gt;- Bob Gezelter, &lt;A href="http://www.rlgsc.com" target="_blank"&gt;http://www.rlgsc.com&lt;/A&gt;</description>
      <pubDate>Sat, 09 Jan 2010 00:37:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560935#M43367</guid>
      <dc:creator>Robert Gezelter</dc:creator>
      <dc:date>2010-01-09T00:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: porting C to C++ on OpenVMS</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560936#M43368</link>
      <description>Even if you decide to still use the C compiler, compiling with C++ will give you "lint clean" source that is fully prototyped.  (Hopefully you will centralize the prototypes in headers.)&lt;BR /&gt;&lt;BR /&gt;Note that declarations like void foo() are valid for C++ but not for scummy C.  You need to add void: void foo(void)&lt;BR /&gt;&lt;BR /&gt;You may also want to compile with C99 where missing prototypes is deprecated.&lt;BR /&gt;&lt;BR /&gt;One difference between C and C++ is that const has internal linkage in C++:&lt;BR /&gt;const struct foo bar = { 99 };&lt;BR /&gt;Change to:&lt;BR /&gt;extern const struct foo bar = { 99 };</description>
      <pubDate>Sun, 10 Jan 2010 20:20:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/porting-c-to-c-on-openvms/m-p/4560936#M43368</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-01-10T20:20:05Z</dc:date>
    </item>
  </channel>
</rss>

