kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: bernd@petrovitsch.priv.at (Bernd Petrovitsch)
To: kernelnewbies@lists.kernelnewbies.org
Subject: [RFC]confusions about 'struct' define
Date: Fri, 01 Jun 2012 11:30:51 +0200	[thread overview]
Message-ID: <1338543052.3698.3.camel@thorin> (raw)
In-Reply-To: <CAD+1EGOHPbrdWxV_QBGsP7J8uphHjBUORd2731aYQJ_53oCKpg@mail.gmail.com>

Hi!

On Don, 2012-05-31 at 01:37 +0800, harryxiyou wrote:
> On Thu, May 31, 2012 at 1:20 AM, Gaurav Jain <gjainroorkee@gmail.com> wrote:
[...]
> > Those are forward declarations as they are being used in defining struct
> > bus_attribute. It's nothing special about GNU-C. That's the case for ANSI-C
> > too. Pretty standard.

These actually exists since K&R times.

> Hmmm.., that is to say, they may be used before definitions in this file or
> defined in other files like 'struct iommu_ops;' field (Actually, i can

Yes, that's the only reason. And you can't use it if you need the actual
size of that struct because the compiler doesn't know it (yet).
The main usage scenario is if you need a pointer to it.

> not find this field's
> definition in this file). However, if it has been defined in other
> header files, we need
> not declare here, right?

If you #include that other file, yes.
But it is not trivial in very large projects like the Linux kernel to
keep somewhat logical and clean and circular-free -h files.
And you also do not really want a separate .h file for each struct.

	Bernd
-- 
Bernd Petrovitsch                  Email : bernd at petrovitsch.priv.at
                     LUGA : http://www.luga.at

  reply	other threads:[~2012-06-01  9:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30 16:50 [RFC]confusions about 'struct' define harryxiyou
2012-05-30 17:20 ` Gaurav Jain
2012-05-30 17:37   ` harryxiyou
2012-06-01  9:30     ` Bernd Petrovitsch [this message]
2012-06-04 14:18       ` Sarbojit Ganguly
2012-05-31 16:40 ` michi1 at michaelblizek.twilightparadox.com
  -- strict thread matches above, loose matches on Subject: below --
2012-05-30 18:41 Rajat Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1338543052.3698.3.camel@thorin \
    --to=bernd@petrovitsch.priv.at \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).