qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 00/16] arm: A9MPCore+A15MPCore QOM'ification


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2 00/16] arm: A9MPCore+A15MPCore QOM'ification
Date: Tue, 23 Jul 2013 20:15:40 +0100

On 23 July 2013 03:43, Andreas Färber <address@hidden> wrote:
> v2 improves internal vs. "public" header separation for GIC.
> As before, no feedback was received to address PMM's QOM concerns,
> so this is what we have as design patterns for the moment.

I had a thought about this. Suppose we have our class header
files do something like this:

#ifdef MYCLASS_IMPLEMENTATION
#define PRIVATE
#else
#ifdef __GNUC__
#define PRIVATE __attribute__((deprecated("this is a private field")))
#else
#define PRIVATE
#endif

typedef struct MyObject {
   int publicfield;
   int privatefield PRIVATE;
} MyObject;

Then we can allow both users of the class and the implementation
to share the same header file (obviously only the implementation
defines MYCLASS_IMPLEMENTATION before using it). The users can
embed the struct MyObject with no problems, but if they try
to directly access a private field this happens:

/tmp/zz9.c:22:5: warning: ‘privatefield’ is deprecated (declared at
/tmp/zz9.c:12): this is a private field [-Wdeprecated-declarations]

(Since this is only a safety-guard against accidental uses,
it's OK that it's only present when building with gcc.)

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]