Fossil SCM

Fix various typos in makeheaders.html. Use curly quotes instead of classic and '' quotes (ref: http://www.dwheeler.com/essays/quotes-in-html.html). Format most such quoted text in monospace print.

andygoth 2016-11-04 23:13 andygoth-timeline-ms
Commit 9b960af1294ee942b9aa3530d2ffbd695f104136
1 file changed +93 -85
--- src/makeheaders.html
+++ src/makeheaders.html
@@ -4,11 +4,11 @@
44
<h1 align=center>The Makeheaders Program</h1>
55
66
77
<p>
88
This document describes <em>makeheaders</em>,
9
-a tool that automatically generates ``<code>.h</code>''
9
+a tool that automatically generates &#8220;<code>.h</code>&#8221;
1010
files for a C or C++ programming project.
1111
</p>
1212
1313
1414
<h2>Table Of Contents</h2>
@@ -67,11 +67,11 @@
6767
<ul>
6868
<li> Typedefs.
6969
<li> Structure, union and enumeration declarations.
7070
<li> Function and procedure prototypes.
7171
<li> Preprocessor macros and #defines.
72
-<li> ``extern'' variable declarations.
72
+<li> &#8220;<code>extern</code>&#8221; variable declarations.
7373
</ul>
7474
</p>
7575
7676
<p>
7777
Definitions in C, on the other hand, include these kinds of things:
@@ -89,13 +89,13 @@
8989
is the <em>interface</em> and the definition is the <em>implementation</em>.
9090
</p>
9191
9292
<p>
9393
In C programs, it has always been the tradition that declarations are
94
-put in files with the ``<code>.h</code>'' suffix and definitions are
95
-placed in ``<code>.c</code>'' files.
96
-The .c files contain ``<code>#include</code>'' preprocessor statements
94
+put in files with the &#8220;<code>.h</code>&#8221; suffix and definitions are
95
+placed in &#8220;<code>.c</code>&#8221; files.
96
+The .c files contain &#8220;<code>#include</code>&#8221; preprocessor statements
9797
that cause the contents of .h files to be included as part of the
9898
source code when the .c file is compiled.
9999
In this way, the .h files define the interface to a subsystem and
100100
the .c files define how the subsystem is implemented.
101101
</p>
@@ -262,11 +262,11 @@
262262
263263
<p>
264264
A similar option is -H. Like the lower-case -h option, big -H
265265
generates a single include file on standard output. But unlike
266266
small -h, the big -H only emits prototypes and declarations that
267
-have been designated as ``exportable''.
267
+have been designated as &#8220;exportable&#8221;.
268268
The idea is that -H will generate an include file that defines
269269
the interface to a library.
270270
More will be said about this in section 3.4.
271271
</p>
272272
@@ -293,13 +293,13 @@
293293
then you can supply an empty header filename, like this:
294294
<pre>
295295
makeheaders alpha.c beta.c gamma.c:
296296
</pre>
297297
In this example, makeheaders will scan the three files named
298
-``alpha.c'',
299
-``beta.c'' and
300
-``gamma.c''
298
+&#8220;<code>alpha.c</code>&#8221;,
299
+&#8220;<code>beta.c</code>&#8221; and
300
+&#8220;<code>gamma.c</code>&#8221;
301301
but because of the colon on the end of third filename
302302
it will only generate headers for the first two files.
303303
Unfortunately,
304304
it is not possible to get makeheaders to process any file whose
305305
name contains a colon.
@@ -309,14 +309,14 @@
309309
In a large project, the length of the command line for makeheaders
310310
can become very long.
311311
If the operating system doesn't support long command lines
312312
(example: DOS and Win32) you may not be able to list all of the
313313
input files in the space available.
314
-In that case, you can use the ``-f'' option followed
314
+In that case, you can use the &#8220;<code>-f</code>&#8221; option followed
315315
by the name of a file to cause makeheaders to read command line
316316
options and filename from the file instead of from the command line.
317
-For example, you might prepare a file named ``mkhdr.dat''
317
+For example, you might prepare a file named &#8220;<code>mkhdr.dat</code>&#8221;
318318
that contains text like this:
319319
<pre>
320320
src/alpha.c:hdr/alpha.h
321321
src/beta.c:hdr/beta.h
322322
src/gamma.c:hdr/gamma.h
@@ -327,18 +327,18 @@
327327
makeheaders -f mkhdr.dat
328328
</pre>
329329
</p>
330330
331331
<p>
332
-The ``-local'' option causes makeheaders to
333
-generate of prototypes for ``static'' functions and
332
+The &#8220;<code>-local</code>&#8221; option causes makeheaders to
333
+generate of prototypes for &#8220;<code>static</code>&#8221; functions and
334334
procedures.
335335
Such prototypes are normally omitted.
336336
</p>
337337
338338
<p>
339
-Finally, makeheaders also includes a ``-doc'' option.
339
+Finally, makeheaders also includes a &#8220;<code>-doc</code>&#8221; option.
340340
This command line option prevents makeheaders from generating any
341341
headers at all.
342342
Instead, makeheaders will write to standard output
343343
information about every definition and declaration that it encounters
344344
in its scan of source files.
@@ -352,19 +352,21 @@
352352
</p>
353353
354354
<p>
355355
If you forget what command line options are available, or forget
356356
their exact name, you can invoke makeheaders using an unknown
357
-command line option (like ``--help'' or ``-?'')
357
+command line option (like &#8220;<code>--help</code>&#8221; or
358
+&#8220;<code>-?</code>&#8221;)
358359
and it will print a summary of the available options on standard
359360
error.
360
-If you need to process a file whose name begins with ``-'',
361
-you can prepend a ``./'' to its name in order to get it
361
+If you need to process a file whose name begins with
362
+&#8220;<code>-</code>&#8221;,
363
+you can prepend a &#8220;<code>./</code>&#8221; to its name in order to get it
362364
accepted by the command line parser.
363
-Or, you can insert the special option ``--'' on the command
364
-line to cause all subsequent command line arguments to be treated as
365
-filenames even if their names beginn with ``-''.
365
+Or, you can insert the special option &#8220;<code>--</code>&#8221; on the
366
+command line to cause all subsequent command line arguments to be treated as
367
+filenames even if their names begin with &#8220;<code>-</code>&#8221;.
366368
</p>
367369
368370
<a name="H0006"></a>
369371
<h2>3.0 Preparing Source Files For Use With Makeheaders</h2>
370372
@@ -379,30 +381,31 @@
379381
380382
<a name="H0007"></a>
381383
<h3>3.1 The Basic Setup</h3>
382384
383385
<p>
384
-The simpliest way to use makeheaders is to put all definitions in
386
+The simplest way to use makeheaders is to put all definitions in
385387
one or more .c files and all structure and type declarations in
386388
separate .h files.
387389
The only restriction is that you should take care to chose basenames
388
-for your .h files that are different from the basenames for you
390
+for your .h files that are different from the basenames for your
389391
.c files.
390
-Recall that if your .c file is named (for example) ``alpha.c''
392
+Recall that if your .c file is named (for example)
393
+&#8220;<code>alpha.c</code>&#8221;
391394
makeheaders will attempt to generate a corresponding header file
392
-named ``alpha.h''.
395
+named &#8220;<code>alpha.h</code>&#8221;.
393396
For that reason, you don't want to use that name for
394397
any of the .h files you write since that will prevent makeheaders
395398
from generating the .h file automatically.
396399
</p>
397400
398401
<p>
399402
The structure of a .c file intented for use with makeheaders is very
400403
simple.
401
-All you have to do is add a single ``#include'' to the top
402
-of the file that sources the header file that makeheaders will generate.
403
-Hence, the beginning of a source file named ``alpha.c''
404
+All you have to do is add a single &#8220;<code>#include</code>&#8221; to the
405
+top of the file that sources the header file that makeheaders will generate.
406
+Hence, the beginning of a source file named &#8220;<code>alpha.c</code>&#8221;
404407
might look something like this:
405408
</p>
406409
407410
<pre>
408411
/*
@@ -415,14 +418,14 @@
415418
416419
<p>
417420
Your manually generated header files require no special attention at all.
418421
Code them as you normally would.
419422
However, makeheaders will work better if you omit the
420
-``#if'' statements people often put around the outside of
423
+&#8220;<code>#if</code>&#8221; statements people often put around the outside of
421424
header files that prevent the files from being included more than once.
422
-For example, to create a header file named ``beta.h'', many
423
-people will habitually write the following:
425
+For example, to create a header file named &#8220;<code>beta.h</code>&#8221;,
426
+many people will habitually write the following:
424427
425428
<pre>
426429
#ifndef BETA_H
427430
#define BETA_H
428431
@@ -435,11 +438,11 @@
435438
Remember that the header files you write will never really be
436439
included by any C code.
437440
Instead, makeheaders will scan your header files to extract only
438441
those declarations that are needed by individual .c files and then
439442
copy those declarations to the .h files corresponding to the .c files.
440
-Hence, the ``#if'' wrapper serves no useful purpose.
443
+Hence, the &#8220;<code>#if</code>&#8221; wrapper serves no useful purpose.
441444
But it does make makeheaders work harder, forcing it to put
442445
the statements
443446
444447
<pre>
445448
#if !defined(BETA_H)
@@ -465,11 +468,11 @@
465468
</p>
466469
467470
<p>
468471
Note that
469472
the wildcard expression used in the above example,
470
-``<code>*.[ch]</code>'',
473
+&#8220;<code>*.[ch]</code>&#8221;,
471474
will expand to include all .h files in the current directory, both
472475
those entered manually be the programmer and others generated automatically
473476
by a prior run of makeheaders.
474477
But that is not a problem.
475478
The makeheaders program will recognize and ignore any files it
@@ -489,14 +492,14 @@
489492
<p><li>
490493
When a function is defined in any .c file, a prototype of that function
491494
is placed in the generated .h file of every .c file that
492495
calls the function.</p>
493496
494
-<P>If the ``static'' keyword of C appears at the beginning
495
-of the function definition, the prototype is suppressed.
496
-If you use the ``LOCAL'' keyword where you would normally
497
-say ``static'', then a prototype is generated, but it
497
+<P>If the &#8220;<code>static</code>&#8221; keyword of C appears at the
498
+beginning of the function definition, the prototype is suppressed.
499
+If you use the &#8220;<code>LOCAL</code>&#8221; keyword where you would normally
500
+say &#8220;<code>static</code>&#8221;, then a prototype is generated, but it
498501
will only appear in the single header file that corresponds to the
499502
source file containing the function. For example, if the file
500503
<code>alpha.c</code> contains the following:
501504
<pre>
502505
LOCAL int testFunc(void){
@@ -509,24 +512,26 @@
509512
LOCAL int testFunc(void);
510513
</pre>
511514
However, no other generated header files will contain a prototype for
512515
<code>testFunc()</code> since the function has only file scope.</p>
513516
514
-<p>When the ``LOCAL'' keyword is used, makeheaders will also
515
-generate a #define for LOCAL, like this:
517
+<p>When the &#8220;<code>LOCAL</code>&#8221; keyword is used, makeheaders will
518
+also generate a #define for LOCAL, like this:
516519
<pre>
517520
#define LOCAL static
518521
</pre>
519522
so that the C compiler will know what it means.</p>
520523
521
-<p>If you invoke makeheaders with a ``-local'' command-line
522
-option, then it treats the ``static'' keyword like
523
-``LOCAL'' and generates prototypes in the header file
524
-that corresponds to the source file containing the function defintiion.</p>
524
+<p>If you invoke makeheaders with a &#8220;<code>-local</code>&#8221;
525
+command-line option, then it treats the &#8220;<code>static</code>&#8221;
526
+keyword like &#8220;<code>LOCAL</code>&#8221; and generates prototypes in the
527
+header file that corresponds to the source file containing the function
528
+definition.</p>
525529
526530
<p><li>
527
-When a global variable is defined in a .c file, an ``extern''
531
+When a global variable is defined in a .c file, an
532
+&#8220;<code>extern</code>&#8221;
528533
declaration of that variable is placed in the header of every
529534
.c file that uses the variable.
530535
</p>
531536
532537
<p><li>
@@ -550,12 +555,12 @@
550555
551556
<p><li>
552557
When a structure, union or enumeration declaration appears in a .h
553558
file, makeheaders will automatically
554559
generate a typedef that allows the declaration to be referenced without
555
-the ``struct'', ``union'' or ``enum''
556
-qualifier.
560
+the &#8220;<code>struct</code>&#8221;, &#8220;<code>union</code>&#8221; or
561
+&#8220;<code>enum</code>&#8221; qualifier.
557562
In other words, if makeheaders sees the code:
558563
<pre>
559564
struct Examp { /* ... */ };
560565
</pre>
561566
it will automatically generate a corresponding typedef like this:
@@ -572,13 +577,13 @@
572577
</ul>
573578
574579
<p>
575580
As a final note, we observe that automatically generated declarations
576581
are ordered as required by the ANSI-C programming language.
577
-If the declaration of some structure ``X'' requires a prior
578
-declaration of another structure ``Y'', then Y will appear
579
-first in the generated headers.
582
+If the declaration of some structure &#8220;<code>X</code>&#8221; requires a
583
+prior declaration of another structure &#8220;<code>Y</code>&#8221;, then Y will
584
+appear first in the generated headers.
580585
</p>
581586
582587
<a name="H0009"></a>
583588
<h3>3.3 How To Avoid Having To Write Any Header Files</h3>
584589
@@ -611,18 +616,18 @@
611616
<pre>
612617
#if INTERFACE
613618
#endif
614619
</pre>
615620
Thus any structure definitions that appear after the
616
-``#if INTERFACE'' but before the corresponding
617
-``#endif'' are eligable to be copied into the
621
+&#8220;<code>#if INTERFACE</code>&#8221; but before the corresponding
622
+&#8220;<code>#endif</code>&#8221; are eligable to be copied into the
618623
automatically generated
619624
.h files of other .c files.
620625
</p>
621626
622627
<p>
623
-If you use the ``#if INTERFACE'' mechanism in a .c file,
628
+If you use the &#8220;<code>#if INTERFACE</code>&#8221; mechanism in a .c file,
624629
then the generated header for that .c file will contain a line
625630
like this:
626631
<pre>
627632
#define INTERFACE 0
628633
</pre>
@@ -637,15 +642,15 @@
637642
</p>
638643
639644
<p>
640645
Note that you don't have to use this approach exclusively.
641646
You can put some declarations in .h files and others within the
642
-``#if INTERFACE'' regions of .c files.
647
+&#8220;<code>#if INTERFACE</code>&#8221; regions of .c files.
643648
Makeheaders treats all declarations alike, no matter where they
644649
come from.
645650
You should also note that a single .c file can contain as many
646
-``#if INTERFACE'' regions as desired.
651
+&#8220;<code>#if INTERFACE</code>&#8221; regions as desired.
647652
</p>
648653
649654
<a name="H0010"></a>
650655
<h3>3.4 Designating Declarations For Export</h3>
651656
@@ -664,11 +669,11 @@
664669
like this, but makeheaders does.
665670
</p>
666671
667672
<p>
668673
Using makeheaders, it is possible to designate routines and data
669
-structures as being for ``export''.
674
+structures as being for &#8220;<code>export</code>&#8221;.
670675
Exported objects are visible not only to other files within the
671676
same library or subassembly but also to other
672677
libraries and subassemblies in the larger program.
673678
By default, makeheaders only makes objects visible to other members
674679
of the same library.
@@ -690,14 +695,14 @@
690695
691696
<p>
692697
But trouble quickly arises when we attempt to devise a mechanism for
693698
telling makeheaders which prototypes it should export and which it should
694699
keep local.
695
-The built-in ``static'' keyword of C works well for prohibiting
696
-prototypes from leaving a single source file, but because C doesn't
700
+The built-in &#8220;<code>static</code>&#8221; keyword of C works well for
701
+prohibiting prototypes from leaving a single source file, but because C doesn't
697702
support a linkage hierarchy, there is nothing in the C language to help us.
698
-We'll have to invite our own keyword: ``EXPORT''
703
+We'll have to invite our own keyword: &#8220;<code>EXPORT</code>&#8221;
699704
</p>
700705
701706
<p>
702707
Makeheaders allows the EXPORT keyword to precede any function or
703708
procedure definition.
@@ -726,15 +731,15 @@
726731
<pre>
727732
#if EXPORT_INTERFACE
728733
#endif
729734
</pre>
730735
will become part of the exported interface.
731
-The ``#if EXPORT_INTERFACE'' mechanism can be used in either
732
-.c or .h files.
733
-(The ``#if INTERFACE'' can also be used in both .h and .c files,
734
-but since it's use in a .h file would be redundant, we haven't mentioned
735
-it before.)
736
+The &#8220;<code>#if EXPORT_INTERFACE</code>&#8221; mechanism can be used in
737
+either .c or .h files.
738
+(The &#8220;<code>#if INTERFACE</code>&#8221; can also be used in both .h and
739
+.c files, but since it's use in a .h file would be redundant, we haven't
740
+mentioned it before.)
736741
</p>
737742
738743
<a name="H0011"></a>
739744
<h3>3.5 Local declarations processed by makeheaders</h3>
740745
@@ -742,11 +747,11 @@
742747
Structure declarations and typedefs that appear in .c files are normally
743748
ignored by makeheaders.
744749
Such declarations are only intended for use by the source file in which
745750
they appear and so makeheaders doesn't need to copy them into any
746751
generated header files.
747
-We call such declarations ``private''.
752
+We call such declarations &#8220;<code>private</code>&#8221;.
748753
</p>
749754
750755
<p>
751756
Sometimes it is convenient to have makeheaders sort a sequence
752757
of private declarations into the correct order for us automatically.
@@ -764,12 +769,13 @@
764769
within
765770
<pre>
766771
#if LOCAL_INTERFACE
767772
#endif
768773
</pre>
769
-A ``LOCAL_INTERFACE'' block works very much like the
770
-``INTERFACE'' and ``EXPORT_INTERFACE''
774
+A &#8220;<code>LOCAL_INTERFACE</code>&#8221; block works very much like the
775
+&#8220;<code>INTERFACE</code>&#8221; and
776
+&#8220;<code>EXPORT_INTERFACE</code>&#8221;
771777
blocks described above, except that makeheaders insures that the
772778
objects declared in a LOCAL_INTERFACE are only visible to the
773779
file containing the LOCAL_INTERFACE.
774780
</p>
775781
@@ -777,11 +783,12 @@
777783
<h3>3.6 Using Makeheaders With C++ Code</h3>
778784
779785
<p>
780786
You can use makeheaders to generate header files for C++ code, in
781787
addition to C.
782
-Makeheaders will recognize and copy both ``class'' declarations
788
+Makeheaders will recognize and copy both &#8220;<code>class</code>&#8221;
789
+declarations
783790
and inline function definitions, and it knows not to try to generate
784791
prototypes for methods.
785792
</p>
786793
787794
<p>
@@ -805,20 +812,20 @@
805812
C++ input. Makeheaders will recognize that its source code is C++
806813
by the suffix on the source code filename. Simple ".c" or ".h" suffixes
807814
are assumed to be ANSI-C. Anything else, including ".cc", ".C" and
808815
".cpp" is assumed to be C++.
809816
The name of the header file generated by makeheaders is derived from
810
-by the name of the source file by converting every "c" to "h" and
817
+the name of the source file by converting every "c" to "h" and
811818
every "C" to "H" in the suffix of the filename.
812819
Thus the C++ source
813
-file ``alpha.cpp'' will induce makeheaders to
814
-generate a header file named ``alpha.hpp''.
820
+file &#8220;<code>alpha.cpp</code>&#8221; will induce makeheaders to
821
+generate a header file named &#8220;<code>alpha.hpp</code>&#8221;.
815822
</p>
816823
817824
<p>
818825
Makeheaders augments class definitions by inserting prototypes to
819
-methods were appropriate. If a method definition begins with one
826
+methods where appropriate. If a method definition begins with one
820827
of the special keywords <b>PUBLIC</b>, <b>PROTECTED</b>, or
821828
<b>PRIVATE</b> (in upper-case to distinguish them from the regular
822829
C++ keywords with the same meaning) then a prototype for that
823830
method will be inserted into the class definition. If none of
824831
these keywords appear, then the prototype is not inserted. For
@@ -867,11 +874,11 @@
867874
<h4>3.6.1 C++ Limitations</h4>
868875
869876
<p>
870877
Makeheaders does not understand more recent
871878
C++ syntax such as templates and namespaces.
872
-Perhaps these issued will be addressed in future revisions.
879
+Perhaps these issues will be addressed in future revisions.
873880
</p>
874881
875882
<a name="H0013"></a>
876883
<h3>3.7 Conditional Compilation</h3>
877884
@@ -879,13 +886,13 @@
879886
The makeheaders program understands and tracks the conditional
880887
compilation constructs in the source code files it scans.
881888
Hence, if the following code appears in a source file
882889
<pre>
883890
#ifdef UNIX
884
- # define WORKS_WELL 1
891
+ # define WORKS_WELL 1
885892
#else
886
- # define WORKS_WELL 0
893
+ # define WORKS_WELL 0
887894
#endif
888895
</pre>
889896
then the next patch of code will appear in the generated header for
890897
every .c file that uses the WORKS_WELL constant:
891898
<pre>
@@ -918,12 +925,12 @@
918925
<p>
919926
Makeheaders does not understand the old K&amp;R style of function
920927
and procedure definitions.
921928
It only understands the modern ANSI-C style, and will probably
922929
become very confused if it encounters an old K&amp;R function.
923
-You should take care to avoid putting K&amp;R function defintions
924
-in your code, therefore.
930
+Therefore you should take care to avoid putting K&amp;R function definitions
931
+in your code.
925932
</p>
926933
927934
<p>
928935
Makeheaders does not understand when you define more than one
929936
global variable with the same type separated by a comma.
@@ -993,35 +1000,35 @@
9931000
in the code, it is not necessary to make a corresponding change
9941001
in a separate document. Just rerun the documentation generator.
9951002
</ul>
9961003
The makeheaders program does not generate program documentation itself.
9971004
But you can use makeheaders to parse the program source code, extract
998
-the information that is relavant to the documentation and to pass this
1005
+the information that is relevant to the documentation and to pass this
9991006
information to another tool to do the actual documentation preparation.
10001007
</p>
10011008
10021009
<p>
1003
-When makeheaders is run with the ``-doc'' option, it emits
1004
-no header files at all.
1010
+When makeheaders is run with the &#8220;<code>-doc</code>&#8221; option, it
1011
+emits no header files at all.
10051012
Instead, it does a complete dump of its internal tables to standard
1006
-outputs in a form that is easily parsed.
1013
+output in a form that is easily parsed.
10071014
This output can then be used by another program (the implementation
10081015
of which is left as an exercise to the reader) that will use the
10091016
information to prepare suitable documentation.
10101017
</p>
10111018
10121019
<p>
1013
-The ``-doc'' option causes makeheaders to print information
1014
-to standard output about all of the following objects:
1020
+The &#8220;<code>-doc</code>&#8221; option causes makeheaders to print
1021
+information to standard output about all of the following objects:
10151022
<ul>
1016
-<li> C++ Class declarations
1023
+<li> C++ class declarations
10171024
<li> Structure and union declarations
10181025
<li> Enumerations
10191026
<li> Typedefs
10201027
<li> Procedure and function definitions
10211028
<li> Global variables
1022
-<li> Preprocessor macros (ex: ``#define'')
1029
+<li> Preprocessor macros (ex: &#8220;<code>#define</code>&#8221;)
10231030
</ul>
10241031
For each of these objects, the following information is output:
10251032
<ul>
10261033
<li> The name of the object.
10271034
<li> The type of the object. (Structure, typedef, macro, etc.)
@@ -1029,11 +1036,12 @@
10291036
an EXPORT_INTERFACE block) or local (contained with LOCAL_INTERFACE).
10301037
<li> A flag to indicate if the object is declared in a C++ file.
10311038
<li> The name of the file in which the object was declared.
10321039
<li> The complete text of any block comment that preceeds the declarations.
10331040
<li> If the declaration occurred inside a preprocessor conditional
1034
- (``#if'') then the text of that conditional is provided.
1041
+ (&#8220;<code>#if</code>&#8221;) then the text of that conditional is
1042
+ provided.
10351043
<li> The complete text of a declaration for the object.
10361044
</ul>
10371045
The exact output format will not be described here.
10381046
It is simple to understand and parse and should be obvious to
10391047
anyone who inspects some sample output.
@@ -1042,11 +1050,11 @@
10421050
<a name="H0016"></a>
10431051
<h2>5.0 Compiling The Makeheaders Program</h2>
10441052
10451053
<p>
10461054
The source code for makeheaders is a single file of ANSI-C code,
1047
-less than 3000 lines in length.
1055
+approximately 3000 lines in length.
10481056
The program makes only modest demands of the system and C library
10491057
and should compile without alteration on most ANSI C compilers
10501058
and on most operating systems.
10511059
It is known to compile using several variations of GCC for Unix
10521060
as well as Cygwin32 and MSVC 5.0 for Win32.
10531061
--- src/makeheaders.html
+++ src/makeheaders.html
@@ -4,11 +4,11 @@
4 <h1 align=center>The Makeheaders Program</h1>
5
6
7 <p>
8 This document describes <em>makeheaders</em>,
9 a tool that automatically generates ``<code>.h</code>''
10 files for a C or C++ programming project.
11 </p>
12
13
14 <h2>Table Of Contents</h2>
@@ -67,11 +67,11 @@
67 <ul>
68 <li> Typedefs.
69 <li> Structure, union and enumeration declarations.
70 <li> Function and procedure prototypes.
71 <li> Preprocessor macros and #defines.
72 <li> ``extern'' variable declarations.
73 </ul>
74 </p>
75
76 <p>
77 Definitions in C, on the other hand, include these kinds of things:
@@ -89,13 +89,13 @@
89 is the <em>interface</em> and the definition is the <em>implementation</em>.
90 </p>
91
92 <p>
93 In C programs, it has always been the tradition that declarations are
94 put in files with the ``<code>.h</code>'' suffix and definitions are
95 placed in ``<code>.c</code>'' files.
96 The .c files contain ``<code>#include</code>'' preprocessor statements
97 that cause the contents of .h files to be included as part of the
98 source code when the .c file is compiled.
99 In this way, the .h files define the interface to a subsystem and
100 the .c files define how the subsystem is implemented.
101 </p>
@@ -262,11 +262,11 @@
262
263 <p>
264 A similar option is -H. Like the lower-case -h option, big -H
265 generates a single include file on standard output. But unlike
266 small -h, the big -H only emits prototypes and declarations that
267 have been designated as ``exportable''.
268 The idea is that -H will generate an include file that defines
269 the interface to a library.
270 More will be said about this in section 3.4.
271 </p>
272
@@ -293,13 +293,13 @@
293 then you can supply an empty header filename, like this:
294 <pre>
295 makeheaders alpha.c beta.c gamma.c:
296 </pre>
297 In this example, makeheaders will scan the three files named
298 ``alpha.c'',
299 ``beta.c'' and
300 ``gamma.c''
301 but because of the colon on the end of third filename
302 it will only generate headers for the first two files.
303 Unfortunately,
304 it is not possible to get makeheaders to process any file whose
305 name contains a colon.
@@ -309,14 +309,14 @@
309 In a large project, the length of the command line for makeheaders
310 can become very long.
311 If the operating system doesn't support long command lines
312 (example: DOS and Win32) you may not be able to list all of the
313 input files in the space available.
314 In that case, you can use the ``-f'' option followed
315 by the name of a file to cause makeheaders to read command line
316 options and filename from the file instead of from the command line.
317 For example, you might prepare a file named ``mkhdr.dat''
318 that contains text like this:
319 <pre>
320 src/alpha.c:hdr/alpha.h
321 src/beta.c:hdr/beta.h
322 src/gamma.c:hdr/gamma.h
@@ -327,18 +327,18 @@
327 makeheaders -f mkhdr.dat
328 </pre>
329 </p>
330
331 <p>
332 The ``-local'' option causes makeheaders to
333 generate of prototypes for ``static'' functions and
334 procedures.
335 Such prototypes are normally omitted.
336 </p>
337
338 <p>
339 Finally, makeheaders also includes a ``-doc'' option.
340 This command line option prevents makeheaders from generating any
341 headers at all.
342 Instead, makeheaders will write to standard output
343 information about every definition and declaration that it encounters
344 in its scan of source files.
@@ -352,19 +352,21 @@
352 </p>
353
354 <p>
355 If you forget what command line options are available, or forget
356 their exact name, you can invoke makeheaders using an unknown
357 command line option (like ``--help'' or ``-?'')
 
358 and it will print a summary of the available options on standard
359 error.
360 If you need to process a file whose name begins with ``-'',
361 you can prepend a ``./'' to its name in order to get it
 
362 accepted by the command line parser.
363 Or, you can insert the special option ``--'' on the command
364 line to cause all subsequent command line arguments to be treated as
365 filenames even if their names beginn with ``-''.
366 </p>
367
368 <a name="H0006"></a>
369 <h2>3.0 Preparing Source Files For Use With Makeheaders</h2>
370
@@ -379,30 +381,31 @@
379
380 <a name="H0007"></a>
381 <h3>3.1 The Basic Setup</h3>
382
383 <p>
384 The simpliest way to use makeheaders is to put all definitions in
385 one or more .c files and all structure and type declarations in
386 separate .h files.
387 The only restriction is that you should take care to chose basenames
388 for your .h files that are different from the basenames for you
389 .c files.
390 Recall that if your .c file is named (for example) ``alpha.c''
 
391 makeheaders will attempt to generate a corresponding header file
392 named ``alpha.h''.
393 For that reason, you don't want to use that name for
394 any of the .h files you write since that will prevent makeheaders
395 from generating the .h file automatically.
396 </p>
397
398 <p>
399 The structure of a .c file intented for use with makeheaders is very
400 simple.
401 All you have to do is add a single ``#include'' to the top
402 of the file that sources the header file that makeheaders will generate.
403 Hence, the beginning of a source file named ``alpha.c''
404 might look something like this:
405 </p>
406
407 <pre>
408 /*
@@ -415,14 +418,14 @@
415
416 <p>
417 Your manually generated header files require no special attention at all.
418 Code them as you normally would.
419 However, makeheaders will work better if you omit the
420 ``#if'' statements people often put around the outside of
421 header files that prevent the files from being included more than once.
422 For example, to create a header file named ``beta.h'', many
423 people will habitually write the following:
424
425 <pre>
426 #ifndef BETA_H
427 #define BETA_H
428
@@ -435,11 +438,11 @@
435 Remember that the header files you write will never really be
436 included by any C code.
437 Instead, makeheaders will scan your header files to extract only
438 those declarations that are needed by individual .c files and then
439 copy those declarations to the .h files corresponding to the .c files.
440 Hence, the ``#if'' wrapper serves no useful purpose.
441 But it does make makeheaders work harder, forcing it to put
442 the statements
443
444 <pre>
445 #if !defined(BETA_H)
@@ -465,11 +468,11 @@
465 </p>
466
467 <p>
468 Note that
469 the wildcard expression used in the above example,
470 ``<code>*.[ch]</code>'',
471 will expand to include all .h files in the current directory, both
472 those entered manually be the programmer and others generated automatically
473 by a prior run of makeheaders.
474 But that is not a problem.
475 The makeheaders program will recognize and ignore any files it
@@ -489,14 +492,14 @@
489 <p><li>
490 When a function is defined in any .c file, a prototype of that function
491 is placed in the generated .h file of every .c file that
492 calls the function.</p>
493
494 <P>If the ``static'' keyword of C appears at the beginning
495 of the function definition, the prototype is suppressed.
496 If you use the ``LOCAL'' keyword where you would normally
497 say ``static'', then a prototype is generated, but it
498 will only appear in the single header file that corresponds to the
499 source file containing the function. For example, if the file
500 <code>alpha.c</code> contains the following:
501 <pre>
502 LOCAL int testFunc(void){
@@ -509,24 +512,26 @@
509 LOCAL int testFunc(void);
510 </pre>
511 However, no other generated header files will contain a prototype for
512 <code>testFunc()</code> since the function has only file scope.</p>
513
514 <p>When the ``LOCAL'' keyword is used, makeheaders will also
515 generate a #define for LOCAL, like this:
516 <pre>
517 #define LOCAL static
518 </pre>
519 so that the C compiler will know what it means.</p>
520
521 <p>If you invoke makeheaders with a ``-local'' command-line
522 option, then it treats the ``static'' keyword like
523 ``LOCAL'' and generates prototypes in the header file
524 that corresponds to the source file containing the function defintiion.</p>
 
525
526 <p><li>
527 When a global variable is defined in a .c file, an ``extern''
 
528 declaration of that variable is placed in the header of every
529 .c file that uses the variable.
530 </p>
531
532 <p><li>
@@ -550,12 +555,12 @@
550
551 <p><li>
552 When a structure, union or enumeration declaration appears in a .h
553 file, makeheaders will automatically
554 generate a typedef that allows the declaration to be referenced without
555 the ``struct'', ``union'' or ``enum''
556 qualifier.
557 In other words, if makeheaders sees the code:
558 <pre>
559 struct Examp { /* ... */ };
560 </pre>
561 it will automatically generate a corresponding typedef like this:
@@ -572,13 +577,13 @@
572 </ul>
573
574 <p>
575 As a final note, we observe that automatically generated declarations
576 are ordered as required by the ANSI-C programming language.
577 If the declaration of some structure ``X'' requires a prior
578 declaration of another structure ``Y'', then Y will appear
579 first in the generated headers.
580 </p>
581
582 <a name="H0009"></a>
583 <h3>3.3 How To Avoid Having To Write Any Header Files</h3>
584
@@ -611,18 +616,18 @@
611 <pre>
612 #if INTERFACE
613 #endif
614 </pre>
615 Thus any structure definitions that appear after the
616 ``#if INTERFACE'' but before the corresponding
617 ``#endif'' are eligable to be copied into the
618 automatically generated
619 .h files of other .c files.
620 </p>
621
622 <p>
623 If you use the ``#if INTERFACE'' mechanism in a .c file,
624 then the generated header for that .c file will contain a line
625 like this:
626 <pre>
627 #define INTERFACE 0
628 </pre>
@@ -637,15 +642,15 @@
637 </p>
638
639 <p>
640 Note that you don't have to use this approach exclusively.
641 You can put some declarations in .h files and others within the
642 ``#if INTERFACE'' regions of .c files.
643 Makeheaders treats all declarations alike, no matter where they
644 come from.
645 You should also note that a single .c file can contain as many
646 ``#if INTERFACE'' regions as desired.
647 </p>
648
649 <a name="H0010"></a>
650 <h3>3.4 Designating Declarations For Export</h3>
651
@@ -664,11 +669,11 @@
664 like this, but makeheaders does.
665 </p>
666
667 <p>
668 Using makeheaders, it is possible to designate routines and data
669 structures as being for ``export''.
670 Exported objects are visible not only to other files within the
671 same library or subassembly but also to other
672 libraries and subassemblies in the larger program.
673 By default, makeheaders only makes objects visible to other members
674 of the same library.
@@ -690,14 +695,14 @@
690
691 <p>
692 But trouble quickly arises when we attempt to devise a mechanism for
693 telling makeheaders which prototypes it should export and which it should
694 keep local.
695 The built-in ``static'' keyword of C works well for prohibiting
696 prototypes from leaving a single source file, but because C doesn't
697 support a linkage hierarchy, there is nothing in the C language to help us.
698 We'll have to invite our own keyword: ``EXPORT''
699 </p>
700
701 <p>
702 Makeheaders allows the EXPORT keyword to precede any function or
703 procedure definition.
@@ -726,15 +731,15 @@
726 <pre>
727 #if EXPORT_INTERFACE
728 #endif
729 </pre>
730 will become part of the exported interface.
731 The ``#if EXPORT_INTERFACE'' mechanism can be used in either
732 .c or .h files.
733 (The ``#if INTERFACE'' can also be used in both .h and .c files,
734 but since it's use in a .h file would be redundant, we haven't mentioned
735 it before.)
736 </p>
737
738 <a name="H0011"></a>
739 <h3>3.5 Local declarations processed by makeheaders</h3>
740
@@ -742,11 +747,11 @@
742 Structure declarations and typedefs that appear in .c files are normally
743 ignored by makeheaders.
744 Such declarations are only intended for use by the source file in which
745 they appear and so makeheaders doesn't need to copy them into any
746 generated header files.
747 We call such declarations ``private''.
748 </p>
749
750 <p>
751 Sometimes it is convenient to have makeheaders sort a sequence
752 of private declarations into the correct order for us automatically.
@@ -764,12 +769,13 @@
764 within
765 <pre>
766 #if LOCAL_INTERFACE
767 #endif
768 </pre>
769 A ``LOCAL_INTERFACE'' block works very much like the
770 ``INTERFACE'' and ``EXPORT_INTERFACE''
 
771 blocks described above, except that makeheaders insures that the
772 objects declared in a LOCAL_INTERFACE are only visible to the
773 file containing the LOCAL_INTERFACE.
774 </p>
775
@@ -777,11 +783,12 @@
777 <h3>3.6 Using Makeheaders With C++ Code</h3>
778
779 <p>
780 You can use makeheaders to generate header files for C++ code, in
781 addition to C.
782 Makeheaders will recognize and copy both ``class'' declarations
 
783 and inline function definitions, and it knows not to try to generate
784 prototypes for methods.
785 </p>
786
787 <p>
@@ -805,20 +812,20 @@
805 C++ input. Makeheaders will recognize that its source code is C++
806 by the suffix on the source code filename. Simple ".c" or ".h" suffixes
807 are assumed to be ANSI-C. Anything else, including ".cc", ".C" and
808 ".cpp" is assumed to be C++.
809 The name of the header file generated by makeheaders is derived from
810 by the name of the source file by converting every "c" to "h" and
811 every "C" to "H" in the suffix of the filename.
812 Thus the C++ source
813 file ``alpha.cpp'' will induce makeheaders to
814 generate a header file named ``alpha.hpp''.
815 </p>
816
817 <p>
818 Makeheaders augments class definitions by inserting prototypes to
819 methods were appropriate. If a method definition begins with one
820 of the special keywords <b>PUBLIC</b>, <b>PROTECTED</b>, or
821 <b>PRIVATE</b> (in upper-case to distinguish them from the regular
822 C++ keywords with the same meaning) then a prototype for that
823 method will be inserted into the class definition. If none of
824 these keywords appear, then the prototype is not inserted. For
@@ -867,11 +874,11 @@
867 <h4>3.6.1 C++ Limitations</h4>
868
869 <p>
870 Makeheaders does not understand more recent
871 C++ syntax such as templates and namespaces.
872 Perhaps these issued will be addressed in future revisions.
873 </p>
874
875 <a name="H0013"></a>
876 <h3>3.7 Conditional Compilation</h3>
877
@@ -879,13 +886,13 @@
879 The makeheaders program understands and tracks the conditional
880 compilation constructs in the source code files it scans.
881 Hence, if the following code appears in a source file
882 <pre>
883 #ifdef UNIX
884 # define WORKS_WELL 1
885 #else
886 # define WORKS_WELL 0
887 #endif
888 </pre>
889 then the next patch of code will appear in the generated header for
890 every .c file that uses the WORKS_WELL constant:
891 <pre>
@@ -918,12 +925,12 @@
918 <p>
919 Makeheaders does not understand the old K&amp;R style of function
920 and procedure definitions.
921 It only understands the modern ANSI-C style, and will probably
922 become very confused if it encounters an old K&amp;R function.
923 You should take care to avoid putting K&amp;R function defintions
924 in your code, therefore.
925 </p>
926
927 <p>
928 Makeheaders does not understand when you define more than one
929 global variable with the same type separated by a comma.
@@ -993,35 +1000,35 @@
993 in the code, it is not necessary to make a corresponding change
994 in a separate document. Just rerun the documentation generator.
995 </ul>
996 The makeheaders program does not generate program documentation itself.
997 But you can use makeheaders to parse the program source code, extract
998 the information that is relavant to the documentation and to pass this
999 information to another tool to do the actual documentation preparation.
1000 </p>
1001
1002 <p>
1003 When makeheaders is run with the ``-doc'' option, it emits
1004 no header files at all.
1005 Instead, it does a complete dump of its internal tables to standard
1006 outputs in a form that is easily parsed.
1007 This output can then be used by another program (the implementation
1008 of which is left as an exercise to the reader) that will use the
1009 information to prepare suitable documentation.
1010 </p>
1011
1012 <p>
1013 The ``-doc'' option causes makeheaders to print information
1014 to standard output about all of the following objects:
1015 <ul>
1016 <li> C++ Class declarations
1017 <li> Structure and union declarations
1018 <li> Enumerations
1019 <li> Typedefs
1020 <li> Procedure and function definitions
1021 <li> Global variables
1022 <li> Preprocessor macros (ex: ``#define'')
1023 </ul>
1024 For each of these objects, the following information is output:
1025 <ul>
1026 <li> The name of the object.
1027 <li> The type of the object. (Structure, typedef, macro, etc.)
@@ -1029,11 +1036,12 @@
1029 an EXPORT_INTERFACE block) or local (contained with LOCAL_INTERFACE).
1030 <li> A flag to indicate if the object is declared in a C++ file.
1031 <li> The name of the file in which the object was declared.
1032 <li> The complete text of any block comment that preceeds the declarations.
1033 <li> If the declaration occurred inside a preprocessor conditional
1034 (``#if'') then the text of that conditional is provided.
 
1035 <li> The complete text of a declaration for the object.
1036 </ul>
1037 The exact output format will not be described here.
1038 It is simple to understand and parse and should be obvious to
1039 anyone who inspects some sample output.
@@ -1042,11 +1050,11 @@
1042 <a name="H0016"></a>
1043 <h2>5.0 Compiling The Makeheaders Program</h2>
1044
1045 <p>
1046 The source code for makeheaders is a single file of ANSI-C code,
1047 less than 3000 lines in length.
1048 The program makes only modest demands of the system and C library
1049 and should compile without alteration on most ANSI C compilers
1050 and on most operating systems.
1051 It is known to compile using several variations of GCC for Unix
1052 as well as Cygwin32 and MSVC 5.0 for Win32.
1053
--- src/makeheaders.html
+++ src/makeheaders.html
@@ -4,11 +4,11 @@
4 <h1 align=center>The Makeheaders Program</h1>
5
6
7 <p>
8 This document describes <em>makeheaders</em>,
9 a tool that automatically generates &#8220;<code>.h</code>&#8221;
10 files for a C or C++ programming project.
11 </p>
12
13
14 <h2>Table Of Contents</h2>
@@ -67,11 +67,11 @@
67 <ul>
68 <li> Typedefs.
69 <li> Structure, union and enumeration declarations.
70 <li> Function and procedure prototypes.
71 <li> Preprocessor macros and #defines.
72 <li> &#8220;<code>extern</code>&#8221; variable declarations.
73 </ul>
74 </p>
75
76 <p>
77 Definitions in C, on the other hand, include these kinds of things:
@@ -89,13 +89,13 @@
89 is the <em>interface</em> and the definition is the <em>implementation</em>.
90 </p>
91
92 <p>
93 In C programs, it has always been the tradition that declarations are
94 put in files with the &#8220;<code>.h</code>&#8221; suffix and definitions are
95 placed in &#8220;<code>.c</code>&#8221; files.
96 The .c files contain &#8220;<code>#include</code>&#8221; preprocessor statements
97 that cause the contents of .h files to be included as part of the
98 source code when the .c file is compiled.
99 In this way, the .h files define the interface to a subsystem and
100 the .c files define how the subsystem is implemented.
101 </p>
@@ -262,11 +262,11 @@
262
263 <p>
264 A similar option is -H. Like the lower-case -h option, big -H
265 generates a single include file on standard output. But unlike
266 small -h, the big -H only emits prototypes and declarations that
267 have been designated as &#8220;exportable&#8221;.
268 The idea is that -H will generate an include file that defines
269 the interface to a library.
270 More will be said about this in section 3.4.
271 </p>
272
@@ -293,13 +293,13 @@
293 then you can supply an empty header filename, like this:
294 <pre>
295 makeheaders alpha.c beta.c gamma.c:
296 </pre>
297 In this example, makeheaders will scan the three files named
298 &#8220;<code>alpha.c</code>&#8221;,
299 &#8220;<code>beta.c</code>&#8221; and
300 &#8220;<code>gamma.c</code>&#8221;
301 but because of the colon on the end of third filename
302 it will only generate headers for the first two files.
303 Unfortunately,
304 it is not possible to get makeheaders to process any file whose
305 name contains a colon.
@@ -309,14 +309,14 @@
309 In a large project, the length of the command line for makeheaders
310 can become very long.
311 If the operating system doesn't support long command lines
312 (example: DOS and Win32) you may not be able to list all of the
313 input files in the space available.
314 In that case, you can use the &#8220;<code>-f</code>&#8221; option followed
315 by the name of a file to cause makeheaders to read command line
316 options and filename from the file instead of from the command line.
317 For example, you might prepare a file named &#8220;<code>mkhdr.dat</code>&#8221;
318 that contains text like this:
319 <pre>
320 src/alpha.c:hdr/alpha.h
321 src/beta.c:hdr/beta.h
322 src/gamma.c:hdr/gamma.h
@@ -327,18 +327,18 @@
327 makeheaders -f mkhdr.dat
328 </pre>
329 </p>
330
331 <p>
332 The &#8220;<code>-local</code>&#8221; option causes makeheaders to
333 generate of prototypes for &#8220;<code>static</code>&#8221; functions and
334 procedures.
335 Such prototypes are normally omitted.
336 </p>
337
338 <p>
339 Finally, makeheaders also includes a &#8220;<code>-doc</code>&#8221; option.
340 This command line option prevents makeheaders from generating any
341 headers at all.
342 Instead, makeheaders will write to standard output
343 information about every definition and declaration that it encounters
344 in its scan of source files.
@@ -352,19 +352,21 @@
352 </p>
353
354 <p>
355 If you forget what command line options are available, or forget
356 their exact name, you can invoke makeheaders using an unknown
357 command line option (like &#8220;<code>--help</code>&#8221; or
358 &#8220;<code>-?</code>&#8221;)
359 and it will print a summary of the available options on standard
360 error.
361 If you need to process a file whose name begins with
362 &#8220;<code>-</code>&#8221;,
363 you can prepend a &#8220;<code>./</code>&#8221; to its name in order to get it
364 accepted by the command line parser.
365 Or, you can insert the special option &#8220;<code>--</code>&#8221; on the
366 command line to cause all subsequent command line arguments to be treated as
367 filenames even if their names begin with &#8220;<code>-</code>&#8221;.
368 </p>
369
370 <a name="H0006"></a>
371 <h2>3.0 Preparing Source Files For Use With Makeheaders</h2>
372
@@ -379,30 +381,31 @@
381
382 <a name="H0007"></a>
383 <h3>3.1 The Basic Setup</h3>
384
385 <p>
386 The simplest way to use makeheaders is to put all definitions in
387 one or more .c files and all structure and type declarations in
388 separate .h files.
389 The only restriction is that you should take care to chose basenames
390 for your .h files that are different from the basenames for your
391 .c files.
392 Recall that if your .c file is named (for example)
393 &#8220;<code>alpha.c</code>&#8221;
394 makeheaders will attempt to generate a corresponding header file
395 named &#8220;<code>alpha.h</code>&#8221;.
396 For that reason, you don't want to use that name for
397 any of the .h files you write since that will prevent makeheaders
398 from generating the .h file automatically.
399 </p>
400
401 <p>
402 The structure of a .c file intented for use with makeheaders is very
403 simple.
404 All you have to do is add a single &#8220;<code>#include</code>&#8221; to the
405 top of the file that sources the header file that makeheaders will generate.
406 Hence, the beginning of a source file named &#8220;<code>alpha.c</code>&#8221;
407 might look something like this:
408 </p>
409
410 <pre>
411 /*
@@ -415,14 +418,14 @@
418
419 <p>
420 Your manually generated header files require no special attention at all.
421 Code them as you normally would.
422 However, makeheaders will work better if you omit the
423 &#8220;<code>#if</code>&#8221; statements people often put around the outside of
424 header files that prevent the files from being included more than once.
425 For example, to create a header file named &#8220;<code>beta.h</code>&#8221;,
426 many people will habitually write the following:
427
428 <pre>
429 #ifndef BETA_H
430 #define BETA_H
431
@@ -435,11 +438,11 @@
438 Remember that the header files you write will never really be
439 included by any C code.
440 Instead, makeheaders will scan your header files to extract only
441 those declarations that are needed by individual .c files and then
442 copy those declarations to the .h files corresponding to the .c files.
443 Hence, the &#8220;<code>#if</code>&#8221; wrapper serves no useful purpose.
444 But it does make makeheaders work harder, forcing it to put
445 the statements
446
447 <pre>
448 #if !defined(BETA_H)
@@ -465,11 +468,11 @@
468 </p>
469
470 <p>
471 Note that
472 the wildcard expression used in the above example,
473 &#8220;<code>*.[ch]</code>&#8221;,
474 will expand to include all .h files in the current directory, both
475 those entered manually be the programmer and others generated automatically
476 by a prior run of makeheaders.
477 But that is not a problem.
478 The makeheaders program will recognize and ignore any files it
@@ -489,14 +492,14 @@
492 <p><li>
493 When a function is defined in any .c file, a prototype of that function
494 is placed in the generated .h file of every .c file that
495 calls the function.</p>
496
497 <P>If the &#8220;<code>static</code>&#8221; keyword of C appears at the
498 beginning of the function definition, the prototype is suppressed.
499 If you use the &#8220;<code>LOCAL</code>&#8221; keyword where you would normally
500 say &#8220;<code>static</code>&#8221;, then a prototype is generated, but it
501 will only appear in the single header file that corresponds to the
502 source file containing the function. For example, if the file
503 <code>alpha.c</code> contains the following:
504 <pre>
505 LOCAL int testFunc(void){
@@ -509,24 +512,26 @@
512 LOCAL int testFunc(void);
513 </pre>
514 However, no other generated header files will contain a prototype for
515 <code>testFunc()</code> since the function has only file scope.</p>
516
517 <p>When the &#8220;<code>LOCAL</code>&#8221; keyword is used, makeheaders will
518 also generate a #define for LOCAL, like this:
519 <pre>
520 #define LOCAL static
521 </pre>
522 so that the C compiler will know what it means.</p>
523
524 <p>If you invoke makeheaders with a &#8220;<code>-local</code>&#8221;
525 command-line option, then it treats the &#8220;<code>static</code>&#8221;
526 keyword like &#8220;<code>LOCAL</code>&#8221; and generates prototypes in the
527 header file that corresponds to the source file containing the function
528 definition.</p>
529
530 <p><li>
531 When a global variable is defined in a .c file, an
532 &#8220;<code>extern</code>&#8221;
533 declaration of that variable is placed in the header of every
534 .c file that uses the variable.
535 </p>
536
537 <p><li>
@@ -550,12 +555,12 @@
555
556 <p><li>
557 When a structure, union or enumeration declaration appears in a .h
558 file, makeheaders will automatically
559 generate a typedef that allows the declaration to be referenced without
560 the &#8220;<code>struct</code>&#8221;, &#8220;<code>union</code>&#8221; or
561 &#8220;<code>enum</code>&#8221; qualifier.
562 In other words, if makeheaders sees the code:
563 <pre>
564 struct Examp { /* ... */ };
565 </pre>
566 it will automatically generate a corresponding typedef like this:
@@ -572,13 +577,13 @@
577 </ul>
578
579 <p>
580 As a final note, we observe that automatically generated declarations
581 are ordered as required by the ANSI-C programming language.
582 If the declaration of some structure &#8220;<code>X</code>&#8221; requires a
583 prior declaration of another structure &#8220;<code>Y</code>&#8221;, then Y will
584 appear first in the generated headers.
585 </p>
586
587 <a name="H0009"></a>
588 <h3>3.3 How To Avoid Having To Write Any Header Files</h3>
589
@@ -611,18 +616,18 @@
616 <pre>
617 #if INTERFACE
618 #endif
619 </pre>
620 Thus any structure definitions that appear after the
621 &#8220;<code>#if INTERFACE</code>&#8221; but before the corresponding
622 &#8220;<code>#endif</code>&#8221; are eligable to be copied into the
623 automatically generated
624 .h files of other .c files.
625 </p>
626
627 <p>
628 If you use the &#8220;<code>#if INTERFACE</code>&#8221; mechanism in a .c file,
629 then the generated header for that .c file will contain a line
630 like this:
631 <pre>
632 #define INTERFACE 0
633 </pre>
@@ -637,15 +642,15 @@
642 </p>
643
644 <p>
645 Note that you don't have to use this approach exclusively.
646 You can put some declarations in .h files and others within the
647 &#8220;<code>#if INTERFACE</code>&#8221; regions of .c files.
648 Makeheaders treats all declarations alike, no matter where they
649 come from.
650 You should also note that a single .c file can contain as many
651 &#8220;<code>#if INTERFACE</code>&#8221; regions as desired.
652 </p>
653
654 <a name="H0010"></a>
655 <h3>3.4 Designating Declarations For Export</h3>
656
@@ -664,11 +669,11 @@
669 like this, but makeheaders does.
670 </p>
671
672 <p>
673 Using makeheaders, it is possible to designate routines and data
674 structures as being for &#8220;<code>export</code>&#8221;.
675 Exported objects are visible not only to other files within the
676 same library or subassembly but also to other
677 libraries and subassemblies in the larger program.
678 By default, makeheaders only makes objects visible to other members
679 of the same library.
@@ -690,14 +695,14 @@
695
696 <p>
697 But trouble quickly arises when we attempt to devise a mechanism for
698 telling makeheaders which prototypes it should export and which it should
699 keep local.
700 The built-in &#8220;<code>static</code>&#8221; keyword of C works well for
701 prohibiting prototypes from leaving a single source file, but because C doesn't
702 support a linkage hierarchy, there is nothing in the C language to help us.
703 We'll have to invite our own keyword: &#8220;<code>EXPORT</code>&#8221;
704 </p>
705
706 <p>
707 Makeheaders allows the EXPORT keyword to precede any function or
708 procedure definition.
@@ -726,15 +731,15 @@
731 <pre>
732 #if EXPORT_INTERFACE
733 #endif
734 </pre>
735 will become part of the exported interface.
736 The &#8220;<code>#if EXPORT_INTERFACE</code>&#8221; mechanism can be used in
737 either .c or .h files.
738 (The &#8220;<code>#if INTERFACE</code>&#8221; can also be used in both .h and
739 .c files, but since it's use in a .h file would be redundant, we haven't
740 mentioned it before.)
741 </p>
742
743 <a name="H0011"></a>
744 <h3>3.5 Local declarations processed by makeheaders</h3>
745
@@ -742,11 +747,11 @@
747 Structure declarations and typedefs that appear in .c files are normally
748 ignored by makeheaders.
749 Such declarations are only intended for use by the source file in which
750 they appear and so makeheaders doesn't need to copy them into any
751 generated header files.
752 We call such declarations &#8220;<code>private</code>&#8221;.
753 </p>
754
755 <p>
756 Sometimes it is convenient to have makeheaders sort a sequence
757 of private declarations into the correct order for us automatically.
@@ -764,12 +769,13 @@
769 within
770 <pre>
771 #if LOCAL_INTERFACE
772 #endif
773 </pre>
774 A &#8220;<code>LOCAL_INTERFACE</code>&#8221; block works very much like the
775 &#8220;<code>INTERFACE</code>&#8221; and
776 &#8220;<code>EXPORT_INTERFACE</code>&#8221;
777 blocks described above, except that makeheaders insures that the
778 objects declared in a LOCAL_INTERFACE are only visible to the
779 file containing the LOCAL_INTERFACE.
780 </p>
781
@@ -777,11 +783,12 @@
783 <h3>3.6 Using Makeheaders With C++ Code</h3>
784
785 <p>
786 You can use makeheaders to generate header files for C++ code, in
787 addition to C.
788 Makeheaders will recognize and copy both &#8220;<code>class</code>&#8221;
789 declarations
790 and inline function definitions, and it knows not to try to generate
791 prototypes for methods.
792 </p>
793
794 <p>
@@ -805,20 +812,20 @@
812 C++ input. Makeheaders will recognize that its source code is C++
813 by the suffix on the source code filename. Simple ".c" or ".h" suffixes
814 are assumed to be ANSI-C. Anything else, including ".cc", ".C" and
815 ".cpp" is assumed to be C++.
816 The name of the header file generated by makeheaders is derived from
817 the name of the source file by converting every "c" to "h" and
818 every "C" to "H" in the suffix of the filename.
819 Thus the C++ source
820 file &#8220;<code>alpha.cpp</code>&#8221; will induce makeheaders to
821 generate a header file named &#8220;<code>alpha.hpp</code>&#8221;.
822 </p>
823
824 <p>
825 Makeheaders augments class definitions by inserting prototypes to
826 methods where appropriate. If a method definition begins with one
827 of the special keywords <b>PUBLIC</b>, <b>PROTECTED</b>, or
828 <b>PRIVATE</b> (in upper-case to distinguish them from the regular
829 C++ keywords with the same meaning) then a prototype for that
830 method will be inserted into the class definition. If none of
831 these keywords appear, then the prototype is not inserted. For
@@ -867,11 +874,11 @@
874 <h4>3.6.1 C++ Limitations</h4>
875
876 <p>
877 Makeheaders does not understand more recent
878 C++ syntax such as templates and namespaces.
879 Perhaps these issues will be addressed in future revisions.
880 </p>
881
882 <a name="H0013"></a>
883 <h3>3.7 Conditional Compilation</h3>
884
@@ -879,13 +886,13 @@
886 The makeheaders program understands and tracks the conditional
887 compilation constructs in the source code files it scans.
888 Hence, if the following code appears in a source file
889 <pre>
890 #ifdef UNIX
891 # define WORKS_WELL 1
892 #else
893 # define WORKS_WELL 0
894 #endif
895 </pre>
896 then the next patch of code will appear in the generated header for
897 every .c file that uses the WORKS_WELL constant:
898 <pre>
@@ -918,12 +925,12 @@
925 <p>
926 Makeheaders does not understand the old K&amp;R style of function
927 and procedure definitions.
928 It only understands the modern ANSI-C style, and will probably
929 become very confused if it encounters an old K&amp;R function.
930 Therefore you should take care to avoid putting K&amp;R function definitions
931 in your code.
932 </p>
933
934 <p>
935 Makeheaders does not understand when you define more than one
936 global variable with the same type separated by a comma.
@@ -993,35 +1000,35 @@
1000 in the code, it is not necessary to make a corresponding change
1001 in a separate document. Just rerun the documentation generator.
1002 </ul>
1003 The makeheaders program does not generate program documentation itself.
1004 But you can use makeheaders to parse the program source code, extract
1005 the information that is relevant to the documentation and to pass this
1006 information to another tool to do the actual documentation preparation.
1007 </p>
1008
1009 <p>
1010 When makeheaders is run with the &#8220;<code>-doc</code>&#8221; option, it
1011 emits no header files at all.
1012 Instead, it does a complete dump of its internal tables to standard
1013 output in a form that is easily parsed.
1014 This output can then be used by another program (the implementation
1015 of which is left as an exercise to the reader) that will use the
1016 information to prepare suitable documentation.
1017 </p>
1018
1019 <p>
1020 The &#8220;<code>-doc</code>&#8221; option causes makeheaders to print
1021 information to standard output about all of the following objects:
1022 <ul>
1023 <li> C++ class declarations
1024 <li> Structure and union declarations
1025 <li> Enumerations
1026 <li> Typedefs
1027 <li> Procedure and function definitions
1028 <li> Global variables
1029 <li> Preprocessor macros (ex: &#8220;<code>#define</code>&#8221;)
1030 </ul>
1031 For each of these objects, the following information is output:
1032 <ul>
1033 <li> The name of the object.
1034 <li> The type of the object. (Structure, typedef, macro, etc.)
@@ -1029,11 +1036,12 @@
1036 an EXPORT_INTERFACE block) or local (contained with LOCAL_INTERFACE).
1037 <li> A flag to indicate if the object is declared in a C++ file.
1038 <li> The name of the file in which the object was declared.
1039 <li> The complete text of any block comment that preceeds the declarations.
1040 <li> If the declaration occurred inside a preprocessor conditional
1041 (&#8220;<code>#if</code>&#8221;) then the text of that conditional is
1042 provided.
1043 <li> The complete text of a declaration for the object.
1044 </ul>
1045 The exact output format will not be described here.
1046 It is simple to understand and parse and should be obvious to
1047 anyone who inspects some sample output.
@@ -1042,11 +1050,11 @@
1050 <a name="H0016"></a>
1051 <h2>5.0 Compiling The Makeheaders Program</h2>
1052
1053 <p>
1054 The source code for makeheaders is a single file of ANSI-C code,
1055 approximately 3000 lines in length.
1056 The program makes only modest demands of the system and C library
1057 and should compile without alteration on most ANSI C compilers
1058 and on most operating systems.
1059 It is known to compile using several variations of GCC for Unix
1060 as well as Cygwin32 and MSVC 5.0 for Win32.
1061

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button