From: Grzegorz Kulewski <kangur@polcom.net>
To: linux-kernel@vger.kernel.org
Subject: gcc and aligning
Date: Sat, 10 Jul 2004 20:21:48 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.58.0407102007410.25422@alpha.polcom.net> (raw)
Hi,
I am trying to experiment with real Linux kernel programming. And I have
this question.
I have:
struct tree_node {
struct tree_node *left, *right;
...
};
struct some1 {
struct tree_node n;
...
};
struct some2 {
struct tree_node n;
...
};
And I want to write universal function that searches tree of structs some1
or some2 (but one kind of struct per one tree). Like this:
struct tree_node *search(struct tree_node *root, struct tree_node *key,
size_t size_of_the_struct);
And in this function I want to compare the _rest_ of some1 or some2 (the
key) against other nodes. But gcc can insert some alignment between n and
the rest of some1 or some2. Can I assume that the alignment fill is the
same in all instances of this struct (for example 0 bytes) and use memcmp
to compare bytes from begin_of_the_struct + sizeof(struct tree_node) to
begin_of_the_struct + size_of_the_struct?
Or is there some better solution?
Thanks,
Grzegorz Kulewski
reply other threads:[~2004-07-10 18:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Pine.LNX.4.58.0407102007410.25422@alpha.polcom.net \
--to=kangur@polcom.net \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®