C programming question ....

Ben Duncan bns
Wed Nov 8 08:16:16 PST 2006


Ok, wrote this lil' ole snippet of code to test a theory ...
-------------------------------------------------------------------

typedef void* my_pointer ;

struct rlib;
typedef struct rlib rlib;
typedef void* my_pointer ;

struct rlib;
typedef struct rlib rlib;

struct rlib_signal_functions {
         int (*signal_function)(rlib *, my_pointer);
         my_pointer data;
};

struct rlib_metadata {
         int rlib_value ;
         int rval_formula ;
         char rlib_from_xml [80] ;
         char xml_formula [80] ;
         char rlib_pcode [120] ;
         char *formula_code ;
};

struct rlib {
         int current_page_number;
         int current_line_number;
         int detail_line_count;
         int start_of_new_report;

         int font_point;

         int current_font_point;

         char *output_encoder_name;

};

int main ( int Argc, char **Argv )

struct rlib_signal_functions {
         int (*signal_function)(rlib *, my_pointer);
         my_pointer data;
};

struct rlib_metadata {
         int rlib_value ;
         int rval_formula ;
         char rlib_from_xml [80] ;
         char xml_formula [80] ;
         char rlib_pcode [120] ;
         char *formula_code ;
};

struct rlib {
         int current_page_number;
         int current_line_number;
         int detail_line_count;
         int start_of_new_report;

         int font_point;

         int current_font_point;

         char *output_encoder_name;

};

int main ( int Argc, char **Argv )

......
...................
-------------------------------------------------------

And it COMPILES and works. SO, it seems that

struct rlib;
typedef struct rlib rlib;

Is a way to prototype a Structure ...

Ok, my questions to the REAL C guru's out there is:
Why would you want to do such a thing when simply moving
the ACTUAL structure ahead of things would solve having to
create extra lines of code protyping the structure ?

Thanks ...





-- 
Ben Duncan   - Business Network Solutions, Inc. 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
        - Hanlon's Razor




More information about the Linux-users mailing list