<?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: info : cc Compiler option in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793104#M101877</link>
    <description>ps: see:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://en.wikipedia.org/wiki/Unreachable_code" target="_blank"&gt;http://en.wikipedia.org/wiki/Unreachable_code&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and links from there.</description>
    <pubDate>Sun, 29 May 2011 11:27:31 GMT</pubDate>
    <dc:creator>Hoff</dc:creator>
    <dc:date>2011-05-29T11:27:31Z</dc:date>
    <item>
      <title>info : cc Compiler option</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793099#M101872</link>
      <description>Hi, I have simple c program in which Function prototype and Function definition is present, but I am not calling that function, is there any way to check this during compiler time and linker time or any "cc" complier that through error or warning.&lt;BR /&gt;Simple program.&lt;BR /&gt;main ()&lt;BR /&gt;{&lt;BR /&gt;void add();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void add()&lt;BR /&gt;{}&lt;BR /&gt;in the above program "add" function prototype and definition is present but I am not calling it,so it there any option with "cc", that through error while compiling the program.</description>
      <pubDate>Sun, 29 May 2011 05:25:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793099#M101872</guid>
      <dc:creator>Kernel Tunable parmeter</dc:creator>
      <dc:date>2011-05-29T05:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: info : cc Compiler option</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793100#M101873</link>
      <description>You are asking the compiler to flag something as an error which IS NOT an error!&lt;BR /&gt;&lt;BR /&gt;And if You just mean to flag an uncalled function in the current program unit as informational, how should the compiler know if the source file just includes a function called by some other part/library linked to this main program ?&lt;BR /&gt;&lt;BR /&gt;If at all, then this could be an optional task for the linker/crossrefencer. In fact the VMS linker does this already by listing the routine(s) as defined, but not as referenced:&lt;BR /&gt;&lt;BR /&gt;Symbol              Value           Defined By              Referenced By ...&lt;BR /&gt;------              -----           ----------              -----------------&lt;BR /&gt;ADD                 00010060-R        TMP&lt;BR /&gt;</description>
      <pubDate>Sun, 29 May 2011 07:44:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793100#M101873</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-05-29T07:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: info : cc Compiler option</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793101#M101874</link>
      <description>And to answer the untold question as to why the source of a program includes unused function definitions:&lt;BR /&gt;often a library package needs user defined call back functions, e.g. sorting libraries use user defined comparison functions, or cost  functions in operations research/optimization.&lt;BR /&gt;It is good practice to keep the user routines together with the user main programs.&lt;BR /&gt;&lt;BR /&gt;Of course one can omit the prototype for those uncalled routines, but then again it is better to keep the prototypes in an #include file  supplied by the associated library, to detect mismatches at compile time.</description>
      <pubDate>Sun, 29 May 2011 08:19:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793101#M101874</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-05-29T08:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: info : cc Compiler option</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793102#M101875</link>
      <description>Are you asking about mismatches or unreferenced functions?  If the function declaration and definition are in the same comp unit, the header is included with the source file, then the compiler can compare the two.  Otherwise you need something like lint that looks at lots of source files.  If you aren't calling it, no mismatches can be checked at link time.  Though a linker could remove unreferenced functions.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;main()&lt;BR /&gt;&lt;BR /&gt;For C99 this should be: int main()&lt;BR /&gt;&lt;BR /&gt;&amp;gt;void add();&lt;BR /&gt;&lt;BR /&gt;This is NOT a valid prototype for C but perfectly valid for C++.  You need to have: void add(void);&lt;BR /&gt;&lt;BR /&gt;Since your declaration is inside main, it probably won't be compared with the later definition.  I.e. all file scope declarations should be moved outside of functions.</description>
      <pubDate>Sun, 29 May 2011 11:10:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793102#M101875</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-05-29T11:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: info : cc Compiler option</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793103#M101876</link>
      <description>That code may or may not be unused.  In your contrived single-module example, yes, it is unused.  In a larger and particularly in a non-trivial and multiple-source-module example, that status is not quite as clear to a compiler.&lt;BR /&gt;&lt;BR /&gt;As for an interpretation of your question and depending on your goal and your C compiler and your operating system, there can be options here.&lt;BR /&gt;&lt;BR /&gt;VMS with the HP/Compaq/DEC C compilers:&lt;BR /&gt;&lt;BR /&gt;$ CC /WARN=WARNINGS=UNUSED&lt;BR /&gt;&lt;BR /&gt;The following are found in various clang and gcc compilers:&lt;BR /&gt;&lt;BR /&gt;-Wunreachable-code&lt;BR /&gt;&lt;BR /&gt;-Wunused&lt;BR /&gt;&lt;BR /&gt;-Wunused-function&lt;BR /&gt;&lt;BR /&gt;If you're using gcc, have a look at gcov.  OpenVMS has no analog of gcov, nor tools such as valgrind.  The closest analog is probably the DECset Performance and Coverage Analyzer (PCA) tool.&lt;BR /&gt;&lt;BR /&gt;As for questions such as these, Google can be your friend here.  With the exception of the VMS qualifier syntax, all of this code coverage information gets asked regularly around the Internet, and discussions are readily available via tools including Google. &lt;BR /&gt;&lt;BR /&gt;For a discussion and an example of both what is available using Google and of what Mr Huber is referring to with the inherent local- and global-reference aspects of this particular question, please see this forum posting:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://stackoverflow.com/questions/4813947/how-can-i-know-which-parts-in-the-code-are-never-used" target="_blank"&gt;http://stackoverflow.com/questions/4813947/how-can-i-know-which-parts-in-the-code-are-never-used&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Details and options can also available via the man pages and HELP text with the platforms, as well; with the software documentation.   Reading the manuals does not signify an admission of defeat, after all.&lt;BR /&gt;&lt;BR /&gt;I would also encourage use of the "static" keyword with any of the truly-local functions, as this helps the compiler with determining the status of functions and particularly around whether the functions can be fully inlined and/or the entry-point and even the code can be eliminated.  Put another way, this keyword is how you flag local code within the compilation unit.&lt;BR /&gt;&lt;BR /&gt;C in particular has been a moving target on all platforms over the past twenty years or so, and particularly on VMS.  If you've been at this a while and haven't re-read the full C doc in the past five or ten years, go do that now.   gcc and particularly llvm/clang are very interesting C/C++ compilers, with piles of useful features.  (VMS C changed pretty quickly for a number of years there, too, though it now includes only partial support for C99 and AFAIK none of C1X; partial C99 is the apparent end of the line for the VMS C compiler.)&lt;BR /&gt;&lt;BR /&gt;Also, please go read this 3-part series of postings from one of the folks working on the llvm/clang C compiler:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html" target="_blank"&gt;http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html" target="_blank"&gt;http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html" target="_blank"&gt;http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;For posting questions (a skill which is harder than it looks), please also read and heed this famous article:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.catb.org/~esr/faqs/smart-questions.html" target="_blank"&gt;http://www.catb.org/~esr/faqs/smart-questions.html&lt;/A&gt;</description>
      <pubDate>Sun, 29 May 2011 11:24:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793103#M101876</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2011-05-29T11:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: info : cc Compiler option</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793104#M101877</link>
      <description>ps: see:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://en.wikipedia.org/wiki/Unreachable_code" target="_blank"&gt;http://en.wikipedia.org/wiki/Unreachable_code&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and links from there.</description>
      <pubDate>Sun, 29 May 2011 11:27:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793104#M101877</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2011-05-29T11:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: info : cc Compiler option</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793105#M101878</link>
      <description>Well maybe because on Sunday my system is not professional :-), but neither The VMS /warning nor one of the 'gcc -W' is warning on the OPs code.&lt;BR /&gt;&lt;BR /&gt;A different case would be an unused static function, these are warned through -Wunused-function, because a static function cannot be called from outside file-scope.</description>
      <pubDate>Sun, 29 May 2011 12:01:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/info-cc-compiler-option/m-p/4793105#M101878</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-05-29T12:01:47Z</dc:date>
    </item>
  </channel>
</rss>

