- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: info : cc Compiler option
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
тАО05-28-2011 10:25 PM
тАО05-28-2011 10:25 PM
info : cc Compiler option
Simple program.
main ()
{
void add();
}
void add()
{}
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2011 12:44 AM
тАО05-29-2011 12:44 AM
Re: info : cc Compiler option
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 ?
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:
Symbol Value Defined By Referenced By ...
------ ----- ---------- -----------------
ADD 00010060-R TMP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2011 01:19 AM
тАО05-29-2011 01:19 AM
Re: info : cc Compiler option
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.
It is good practice to keep the user routines together with the user main programs.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2011 04:10 AM
тАО05-29-2011 04:10 AM
Re: info : cc Compiler option
>main()
For C99 this should be: int main()
>void add();
This is NOT a valid prototype for C but perfectly valid for C++. You need to have: void add(void);
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2011 04:24 AM
тАО05-29-2011 04:24 AM
Re: info : cc Compiler option
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.
VMS with the HP/Compaq/DEC C compilers:
$ CC /WARN=WARNINGS=UNUSED
The following are found in various clang and gcc compilers:
-Wunreachable-code
-Wunused
-Wunused-function
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.
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.
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:
http://stackoverflow.com/questions/4813947/how-can-i-know-which-parts-in-the-code-are-never-used
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.
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.
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.)
Also, please go read this 3-part series of postings from one of the folks working on the llvm/clang C compiler:
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html
For posting questions (a skill which is harder than it looks), please also read and heed this famous article:
http://www.catb.org/~esr/faqs/smart-questions.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2011 04:27 AM
тАО05-29-2011 04:27 AM
Re: info : cc Compiler option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2011 05:01 AM
тАО05-29-2011 05:01 AM
Re: info : cc Compiler option
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.