[comp.sys.mac.programmer] THINK C 4.0 Goodies

awd@dbase.UUCP (Alastair Dallas) (08/17/89)

I've discovered a couple of interesting C extensions in THINK C that no
one has mentioned yet:

- #define _H_Include
  in a file called Include.h will cause the compiler to search the .h only
  once, as if you used the (now cliche) construct:
  #ifndef _H_Include
  #define _H_Include 1
    ... your stuff here ...
  #endif

- structures can be open-ended without causing a compiler error, as in:
  struct {
	Rect bBox;
	int sizObj;
	char data[];
	} object;
  This is one of the few things that Pascal examples make this C programmer
  envious of (the other being with..do).

Any comments?

/alastair/

russotto@wam.UMD.EDU (09/12/89)

In article <199@dbase.UUCP> awd@dbase.UUCP (Alastair Dallas) writes:
>- structures can be open-ended without causing a compiler error, as in:
>  struct {
>	Rect bBox;
>	int sizObj;
>	char data[];
>	} object;
>  This is one of the few things that Pascal examples make this C programmer
>  envious of (the other being with..do).
>
>Any comments?
>
>/alastair/
What's the matter with
	struct {
		...
		char data[0];
	} object;
?
It's certainly better than Pascal's 
	Packed Array[0..0] of char;


-- 
DISCLAIMER:  Not only does the University not share my opinions,
	     they don't want me sharing my opinions.
		"This 'Pnews', what does it do?"
	     Matthew T. Russotto
	     russotto@wam.umd.edu