Deep question for the REAL C GURU's out there ...

Ben Duncan bns
Wed Feb 23 17:23:42 PST 2005


Ok, (read on thru for several other questions). I started to use typedef struct,
but ran across a "published" paper saying 'use typedef'ing then define structure'
paper by someone on "C" standards ..Oh well, I guess opinions are like assholes, everyone
has one and it stinks ...

I am NOT , I repeat, NOT offended in anyway, since I am starting to have
the "lights" turn on in my programming on C, any and everything helps.

What I seek to accomplish, since SLAG is going to be OSS'd an probably supported
(hopefully) by bunches of programmers, is to make it easily understandable
on what I am trying to do, and easily maintained, even by novice C coders.

Keep in mind SLAG is going to become the "FoxPro", Delphi, AppGen, FilePro (etc..)
so that Accounting Applications can be developed using it, so those MOST
interested will be coming from such programming backgrounds.

Roger Oberholtzer wrote:
> On Wed, 2005-02-23 at 10:11 -0600, Ben Duncan wrote:

<SNIP>

> 
> /Cruel_to_be_kind_mode (C code clarity is a sore point with me - sorry)
> 

No problem, again, C code clarity is what I striving for. But should clarity
superced efficiency (Just asking) ?

> Does your code compile?

Yes, and even amazingly works ... I was truly dumbfounded ....

> 
> When reviewing your code, it is hard to see what is what in the
> structures. Your typedefs followed by the actual structs is a 'unique'
> style. Declaring the variables with the 'typedef' but declaring the
> variables without it is surprising. 
> 
> I think the more traditional declarations might be as follows. I took
> away the name after the 'struct' as you are not using them. They are
> only useful if the typedef needs to refer to itself.
> 
> typedef struct {
> 
>      int ms_counter ;
>      int ms_users ;
>      char ms_status ;
>      char ms_message [ 80 ] ;
> 
> } menustat;
> 
> typedef struct {
> 
>      int  mli_lineid ;
>      char mli_displayname [ 16 ] ;
>      char mli_type [ 8 ] ;
>      char mli_program [ 24 ] ;
> 
> } menulineitem;
> 
> typedef struct {
> 
>      char menu_heading [ 12 ] ;     /* Also used as Menu ID */
>      int menu_item_count ;          /* How many Line items ? */
>      menulineitem menusetlineitem [ 18 ] ;
>      menustat menuset_status ;
> 
> } Menu;
> 
> Much less stuff and each typedef declared in one instead of two
> statements. Then your variable declarations are ok. 
> 
> You can also just ignore this and please take no offense. I just can't
> resist. My problem, really.
> 

<SNIP>


> Towards that end, be sure to explore the 'static inline' type of C
> function. Hint hint.


Ok, explain 'static inline' type of C function ..


> 
> 

-- 
Ben Duncan   - VersAccounting Software LLC 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