Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Re: C Function Prototype Generator

Re: C Function Prototype Generator

2011-01-20 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "Chuck Hackett" <egroupscdh@...> wrote:
> To those of you that use a C Function Prototype Generator to
> automatically generate function prototypes from C source files:  
In 30+ years of C/C++ programming, I've never used one.  In my estimation they are a solution seeking a problem.  If you're using source code from another party it should already have the necessary prototypes defined.  If you're creating your own source code just copy the type, name and parameter list lines and paste them in the appropriate include file or near the top of the source file depending on whether the particular function if public or private.  Job done.

As an asice, I generally define my functions in this form:

func-type
func-name(parameter-list)
{
    func-statement
}

for example,

uint8_t
foo(uint16_t *bar)
{
}

The key aspect of this (unconventional) format is that it makes it simple in many/most text editors to locate the definition of the function (as opposed to its use).  Assuming the editor provides the functionality of searching for a regular expression over a set of files, the regex ^foo\( will locate the place where the function foo is defined.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

C Function Prototype Generator

2011-01-20 by Chuck Hackett

To those of you that use a C Function Prototype Generator to automatically generate
function prototypes from C source files:  What utility do you use?

I searched AVR Freaks and Source Forge and came up with one called “cproto” but it
needs to be compiled and I don’t have a C compiler for Windows (C#, yes, C, no).

Desireable, but not required, would be one that has parameters that allow specifying
(via a regular expression maybe) what functions to output, such as “*_” but not
“*__” so as (in my case) not output prototypes for “internal” functions.
 
Cheers,

Chuck Hackett
"Good judgment comes from experience, experience comes from bad judgment"
7.5" gauge Union Pacific Northern (4-8-4) 844 http://www.whitetrout.net/Chuck

RE: [AVR-Chat] Re: C Function Prototype Generator

2011-01-21 by Chuck Hackett

> From: Don Kinzer
> 
> --- In AVR-Chat@yahoogroups.com, "Chuck Hackett" <egroupscdh@...> wrote:
> > To those of you that use a C Function Prototype Generator to
> > automatically generate function prototypes from C source files:
> In 30+ years of C/C++ programming, I've never used one.  In my estimation they
> are a solution seeking a problem.  If you're using source code from another
> party it should already have the necessary prototypes defined.  If you're
> creating your own source code just copy the type, name and parameter list
> lines and paste them in the appropriate include file or near the top of the
> source file depending on whether the particular function if public or private.
> Job done.
> ....

True, but I have found them useful in the past in other C-like languages.  

This tool automatically creates the initial header file and propagates changes made
to the functions to keep things up-to-date, all I need to do is add it to the
Makefile.  Yes, WinAVR lets me know if I forget one or forget to update one but,
this way it's automatic.
 
Cheers,

Chuck Hackett
"Good judgment comes from experience, experience comes from bad judgment"
7.5" gauge Union Pacific Northern (4-8-4) 844 http://www.whitetrout.net/Chuck

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.