Re: Problems with cplusplus in source files



Speedy.Gonzales@earthling.net writes:
> while searching for an error with 'purify' (from rational.com) and
> 'gtk', I found the following statements:
> 
> #ifdef __cplusplus
> 	  switch (visual_list[i].c_class)
> #else /* __cplusplus */
> 	  switch (visual_list[i].class)
> #endif /* __cplusplus */
> 
> in the file 'gdk/gdkvisual.c'
> 
> The intention of the author is, that 'class' is a reseved keyword in
> C++, but not in C.

In the X11 headers, that field is called 'class' when using C, and
called 'c_class' when using C++.

X11/Xutil.h:
  typedef struct {
    Visual *visual;
    VisualID visualid;
    int screen;
    int depth;
  #if defined(__cplusplus) || defined(c_plusplus)
    int c_class;					/* C++ */
  #else
    int class;
  #endif
    unsigned long red_mask;
    unsigned long green_mask;

> But is the conceptional intention also, to compile the file two
> times, for C++, C resp.? I don't think so ;-)

No.  You just compile it once.  Once in object code, struct member
names have no meaning -- they just become pointer offsets.  Both the
above compile to the same offset.

- Hari
-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]