### Example Configuration File Content Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html This is an example of the content for a configuration file used with the '-f' option. Each line specifies a source file and its corresponding header file. ```text src/alpha.c:hdr/alpha.h src/beta.c:hdr/beta.h src/gamma.c:hdr/gamma.h ... ``` -------------------------------- ### Conditional Compilation Example Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Demonstrates conditional compilation using #define and #else/#endif directives. ```c #define WORKS_WELL 1 #else #define WORKS_WELL 0 #endif ``` -------------------------------- ### C Source File Setup for Makeheaders Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Include the corresponding header file generated by makeheaders at the top of your C source file. This is a standard setup for files intended for use with makeheaders. ```c /* * Introductory comment... */ #include "alpha.h" /* The rest of your code... */ ``` -------------------------------- ### Makeheaders Command Example Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Run makeheaders with a wildcard expression to process all C and header files in the current directory. The tool intelligently handles files it has already generated. ```bash makeheaders *.[ch] ``` -------------------------------- ### Specify Custom Header File Name Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Map a specific .c file to a .h file with a different name. For example, 'alpha.c' will generate 'beta.h'. ```bash makeheaders alpha.c:beta.h ``` -------------------------------- ### Preprocessor Macros for Block Delimiters Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Example of using preprocessor macros to define block delimiters, which can confuse makeheaders. ```c #define BEGIN { #define END } ``` -------------------------------- ### Multiple Global Variables Declaration (Not Understood by Makeheaders) Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Example of a declaration style that makeheaders does not understand, where multiple global variables of the same type are declared on a single line. ```c int a = 4, b = 5; ``` -------------------------------- ### Exclude Files from Header Generation Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html To process certain .c files but not generate header files for them, provide an empty header filename. This example processes alpha.c, beta.c, and gamma.c without generating headers for them. ```bash makeheaders alpha.c beta.c gamma.c: ``` -------------------------------- ### Structure Declaration Example Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html When makeheaders encounters a structure declaration in a header file, it automatically generates a corresponding typedef for easier referencing. ```c struct Examp { /* ... */ }; ``` ```c typedef struct Examp Examp; ``` -------------------------------- ### Handle Filenames Starting with Hyphen Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html To process a file whose name begins with a hyphen ('-'), prepend './' to its name. Alternatively, use the '--' option to treat all subsequent arguments as filenames. ```bash makeheaders -- -f file-with-leading-hyphen.dat ``` -------------------------------- ### Read Configuration from a File Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Use the -f option to specify a file containing command-line options and filenames. This is useful for long command lines or systems with command-line length limitations. ```bash makeheaders -f mkhdr.dat ``` -------------------------------- ### Generate Headers for All C/H Files Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Use this command to generate a separate .h file for each .c file in the current directory. The .h file will have the same base name as the .c file. ```bash makeheaders *.[ch] ``` -------------------------------- ### Header File Structure for Makeheaders Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Manually written header files should omit standard include guards (#ifndef, #define, #endif) to work better with makeheaders. This allows makeheaders to manage header inclusion more effectively. ```c #ifndef BETA_H #define BETA_H /* declarations for beta.h go here */ #endif ``` -------------------------------- ### Interface/Implementation Delimitation Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Use the #if INTERFACE and #endif directives within a .c file to demarcate sections that should be treated as interface definitions for header generation. ```c #if INTERFACE #endif ``` -------------------------------- ### Include Static Function Prototypes Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html The -local option generates prototypes for 'static' functions and procedures, which are normally omitted. ```bash makeheaders -local *.[ch] ``` -------------------------------- ### Generate Exportable Declarations Header Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html The -H option generates a single include file containing only 'exportable' prototypes and declarations, defining the library's interface. Output is sent to standard output. ```bash makeheaders -H *.[ch] >common.h ``` -------------------------------- ### Generate a Single Common Header File Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Use the -h option to consolidate all declarations from multiple .c files into a single .h file. The output is redirected to 'common.h'. ```bash makeheaders -h *.[ch] >common.h ``` -------------------------------- ### Aggregate Type Declaration (Not Supported) Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Demonstrates aggregate type declarations that makeheaders may not fully support when combined with variable declarations. ```c struct {int field;} a; struct Tag {int field;} b; struct Tag c; ``` -------------------------------- ### Function Definition with Macro Delimiters Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html A function definition using macro-defined block delimiters, illustrating a case where makeheaders might struggle. ```c char *StrDup(const char *zSrc) BEGIN /* Code here */ END ``` -------------------------------- ### Empty Conditional Block Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Illustrates an empty conditional compilation block. ```c #if 0 #endif ``` -------------------------------- ### Multiple Global Variables Declaration (Understood by Makeheaders) Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html The correct way to declare multiple global variables for makeheaders, with each variable on its own line. ```c int a = 4; int b = 5; ``` -------------------------------- ### Handling Conditional Compilation with #ifdef Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Shows how makeheaders recognizes and processes conditional compilation directives within source code files. ```C++ #ifdef UNIX ``` -------------------------------- ### Conditional Compilation with UNIX Define Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Shows conditional compilation based on the presence or absence of the UNIX define. ```c #if defined(UNIX) # define WORKS_WELL 1 #endif #if !defined(UNIX) # define WORKS_WELL 0 #endif ``` -------------------------------- ### Generate Documentation Information Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html The -doc option prevents header generation and instead outputs information about definitions and declarations encountered in source files to standard output. This output is designed for parsing by other documentation generation programs. ```bash makeheaders -doc *.[ch] ``` -------------------------------- ### Augmenting Class Definitions with PUBLIC Keyword Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Demonstrates how makeheaders adds a constructor prototype to a class definition when the PUBLIC keyword precedes the constructor's implementation. This avoids redundant declarations. ```C++ #if INTERFACE class Example1 { private: int v1; }; #endif PUBLIC Example1::Example1(){ v1 = 0; } ``` ```C++ #if INTERFACE class Example1 { private: int v1; public: Example1(); }; #endif Example1::Example1(){ v1 = 0; } ``` -------------------------------- ### Interface Declaration for Aggregate Type Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Shows how to declare an aggregate type within an interface block, which makeheaders can process. ```c #if INTERFACE struct Tag {int field;}; #endif Tag a; Tag b; /* No more than one variable per declaration. */ Tag c; /* So must put each on its own line. */ ``` -------------------------------- ### LOCAL Keyword Usage with Makeheaders Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html When 'LOCAL' is used instead of 'static' for file-scope functions, makeheaders generates a prototype in the corresponding header file and a #define for LOCAL. This ensures the function's scope is correctly represented. ```c LOCAL int testFunc(void){ return 0; } ``` ```c #define LOCAL static LOCAL int testFunc(void); ``` ```c #define LOCAL static ``` -------------------------------- ### Conditional Compilation for Interfaces Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html These preprocessor directives are used to delineate code blocks that should be included in different interface levels. #if INTERFACE is for general interface declarations, while #if EXPORT_INTERFACE is for declarations intended for external export. ```c #if INTERFACE #endif ``` ```c #if EXPORT_INTERFACE #endif ``` -------------------------------- ### Interface Macro Definition Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html When the #if INTERFACE mechanism is used, makeheaders automatically generates a #define INTERFACE 0 directive in the corresponding header file. ```c #define INTERFACE 0 ``` -------------------------------- ### Define EXPORT Macro for Makeheaders Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html When the EXPORT keyword is used in a .c file, makeheaders defines this macro. This macro is used to mark functions and procedures eligible for inclusion in generated header files. ```c #define EXPORT ``` -------------------------------- ### Makeheaders Interface Directives Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html These are preprocessor directives recognized by makeheaders to control the scope and visibility of declarations. LOCAL_INTERFACE is for private declarations, INTERFACE is for general interface declarations, and EXPORT_INTERFACE is for declarations intended for external export. ```c `#if LOCAL_INTERFACE` `#endif` ``` ```c `#if INTERFACE` `#endif` ``` ```c `#if EXPORT_INTERFACE` `#endif` ``` -------------------------------- ### Local Interface Declarations for Makeheaders Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html Use this directive to enclose private declarations that should be processed by makeheaders and included in local header files but not propagated outside the current file. This is useful for static functions or when private declarations are used in function arguments. ```c #if LOCAL_INTERFACE #endif ``` -------------------------------- ### Extern C Declaration for C++ Source: https://fossil-scm.org/home/doc/trunk/tools/makeheaders.html When makeheaders is used with C++ code, it recognizes the need to prepend 'extern "C"' for C functions called from C++ modules. This ensures proper linkage between C and C++ code. ```cpp extern "C" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.