How to extract function prototypes from source code ?

How to extract function prototypes from source code ?

Post by yw.. » Thu, 17 Apr 1997 04:00:00



Hello,

I do remember in GCC there is a switch that can extract function prototypes
(declarations) from C source code into a seperate file so it's easy to
build up header files, but however I cannot find it anymore. Can anyone
help me with this ?

--
Yen-Wei Liu


FAX: +886-2-783-6444

Only those who believe in all that glitters is gold think all that computes is
Microsoft's.

 
 
 

How to extract function prototypes from source code ?

Post by James Youngm » Tue, 22 Apr 1997 04:00:00



says...

Quote:

>Hello,

>I do remember in GCC there is a switch that can extract function prototypes
>(declarations) from C source code into a seperate file so it's easy to
>build up header files, but however I cannot find it anymore. Can anyone
>help me with this ?

You may be thinking of "protoize".
--
James Youngman       VG Gas Analysis Systems  The trouble with the rat-race
Before sending advertising material, read     is, even if you win, you're
http://www.law.cornell.edu/uscode/47/227.html         still a rat.

 
 
 

How to extract function prototypes from source code ?

Post by Dave Plon » Tue, 22 Apr 1997 04:00:00



> Hello,
> I do remember in GCC there is a switch that can extract function prototypes
> (declarations) from C source code into a seperate file so it's easy to
> build up header files, but however I cannot find it anymore. Can anyone
> help me with this ?

There's a freely available code called "mkproto" which does such
a thing.  I picked it up back in '93...  hopefully its been updated
since because It used to get confused by complicated types such as
pointers to functions in argument lists.  (I wrote my own kludges
for those problems.)  Here's some fragments from the man page:

NAME
   mkproto - make prototypes for functions

SYNOPSIS
   mkproto [-n] [-s] [-p] [ file ] ...

...

AUTHOR
   Eric R. Smith.

NOTE
   There is no warranty for this program (as noted above, it's guaranteed
to break sometimes anyways!). Mkproto is in the public domain.

Dave

--

 
 
 

How to extract function prototypes from source code ?

Post by Al A » Mon, 28 Apr 1997 04:00:00


execuse my C naivete
but

perl, awk, sed
would not do
?

: > Hello,

: > I do remember in GCC there is a switch that can extract function prototypes
: > (declarations) from C source code into a seperate file so it's easy to
: > build up header files, but however I cannot find it anymore. Can anyone
: > help me with this ?

: There's a freely available code called "mkproto" which does such
: a thing.  I picked it up back in '93...  hopefully its been updated
: since because It used to get confused by complicated types such as
: pointers to functions in argument lists.  (I wrote my own kludges
: for those problems.)  Here's some fragments from the man page:

: NAME
:    mkproto - make prototypes for functions

: SYNOPSIS
:    mkproto [-n] [-s] [-p] [ file ] ...

: ...

: AUTHOR
:    Eric R. Smith.

: NOTE
:    There is no warranty for this program (as noted above, it's guaranteed
: to break sometimes anyways!). Mkproto is in the public domain.

: Dave

: --

--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, seders moderator                                      sed u soon
               it is not zat we do not see the  s o l u t i o n          
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+

 
 
 

How to extract function prototypes from source code ?

Post by Lam Chi W » Mon, 05 May 1997 04:00:00


Dear Sir,
        I am now writing unix programs on stream file processing and facing a
problem ?  I dont't know which I/O function call (fprintf, fwrite,
...etc) is preemptive and non-preemptive, ie. if process A write a
buffer "1234567890" to file test.txt and process B write a buffer
"abcdefghi" to the same file test.txt simultaneously, is the resulting
file contains the correct output "1234567890abcdefghi" or
"abcdefghi1234567890" because the I/O function call is non-preemptive,
or the resulting file may contain the incorrect output
"abcd12345efghi67890" because the I/O function call is preemptive.

Can anyone tell me which C function call (fprintf, fwrite, ... etc) in
UNIX environment is preemptive and non-preemptive ?


Thank you very much for your help and attention.

 
 
 

How to extract function prototypes from source code ?

Post by Andrew Giert » Mon, 05 May 1997 04:00:00


 Lam> I am now writing unix programs on stream file processing and
 Lam> facing a problem ?  I dont't know which I/O function call
 Lam> (fprintf, fwrite, ....etc) is preemptive and non-preemptive,
 Lam> ie. if process A write a buffer "1234567890" to file test.txt
 Lam> and process B write a buffer "abcdefghi" to the same file
 Lam> test.txt simultaneously, is the resulting file contains the
 Lam> correct output "1234567890abcdefghi" or "abcdefghi1234567890"
 Lam> because the I/O function call is non-preemptive, or the
 Lam> resulting file may contain the incorrect output
 Lam> "abcd12345efghi67890" because the I/O function call is
 Lam> preemptive.

 Lam> Can anyone tell me which C function call (fprintf, fwrite,
 Lam> ... etc) in UNIX environment is preemptive and non-preemptive ?

The term you're looking for here is "atomic".

In general, you can make no assumptions about any of the stdio calls
(fwrite, fprintf etc.). If you need this type of control, you should
use the write() function only. write() calls to a file opened in
append mode (O_APPEND) are atomic *provided*:

  - the file is not remote via NFS

  - the filesystem does not become full during the operation.

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>

 
 
 

How to extract function prototypes from source code ?

Post by nam » Mon, 05 May 1997 04:00:00



> The term you're looking for here is "atomic".
> In general, you can make no assumptions about any of the stdio calls
> (fwrite, fprintf etc.). If you need this type of control, you should
> use the write() function only. write() calls to a file opened in
> append mode (O_APPEND) are atomic *provided*:
>   - the file is not remote via NFS

     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This condition is not necessary I believe.  The O_APPEND will still work
correctly.  It will guarantee that one set of data will appear after the other
set of data, and they won't write over each other.  The machine acting as the
file server keeps track of the fact that the operations are O_APPEND and
guarantees the write() will complete before the other write() does some work.
Try writing a program that does an atomic write on an 8mb piece of data over
an NFS mount.  That process cannot be killed, not even with a -KILL signal.
Even though the data is sent over the network as several chunks, the server
will not let any other data into that file (assuming all have specified the
O_APPEND flag) until after the write() completes.

GREG

 
 
 

How to extract function prototypes from source code ?

Post by Andrew Giert » Mon, 05 May 1997 04:00:00


 [O_APPEND not working over NFS]

 name> This condition is not necessary I believe.  The O_APPEND will
 name> still work correctly.  It will guarantee that one set of data
 name> will appear after the other set of data, and they won't write
 name> over each other.  The machine acting as the file server keeps
 name> track of the fact that the operations are O_APPEND and
 name> guarantees the write() will complete before the other write()
 name> does some work.

That isn't true (the server machine isn't told that the operation is an
O_APPEND write, at least in NFSv2; this may have been fixed in v3).

The problem is more subtle; two clients can do O_APPEND writes that
overwrite each other:

  - client A obtains current file size
  - client B obtains current file size
  - client A writes data at EOF
  - client B writes data at EOF

The two clients end up writing data to the same place.

As I said, this may have been fixed in NFSv3, but at the moment, it's
pretty unwise to assume a particular NFS version, when one of them
screws up horribly :-)

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>

 
 
 

How to extract function prototypes from source code ?

Post by Christopher Michael Coon » Fri, 09 May 1997 04:00:00



: Dear Sir,
:       I am now writing unix programs on stream file processing and facing a
: problem ?  I dont't know which I/O function call (fprintf, fwrite,
: ...etc) is preemptive and non-preemptive, ie. if process A write a
: buffer "1234567890" to file test.txt and process B write a buffer
: "abcdefghi" to the same file test.txt simultaneously, is the resulting
: file contains the correct output "1234567890abcdefghi" or
: "abcdefghi1234567890" because the I/O function call is non-preemptive,
: or the resulting file may contain the incorrect output
: "abcd12345efghi67890" because the I/O function call is preemptive.
:
: Can anyone tell me which C function call (fprintf, fwrite, ... etc) in
: UNIX environment is preemptive and non-preemptive ?
:

:
: Thank you very much for your help and attention.

one option is to sprintf to a buffer and then write() the buffer

--

"Watch me not care" dilbert 19960219       |
Do not meddle in the affairs of Wizards,   |    Do not watch
For you are crunchy and good with ketchup. |     this space