OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / draft / man3 / offsetof.3
index 3a12533..9d784d4 100644 (file)
@@ -1,6 +1,7 @@
 .\" Copyright (C) 2006 Justin Pryzby <pryzbyj@justinpryzby.com>
 .\"     and Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
 .\"
+.\" %%%LICENSE_START(PERMISSIVE_MISC)
 .\" Permission is hereby granted, free of charge, to any person obtaining
 .\" a copy of this software and associated documentation files (the
 .\" "Software"), to deal in the Software without restriction, including
 .\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 .\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 .\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+.\" %%%LICENSE_END
 .\"
 .\" References:
 .\"   /usr/lib/gcc/i486-linux-gnu/4.1.1/include/stddef.h
 .\"   glibc-doc
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
 .\"
 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI
 .\"                             all rights reserved.
 .\" Translated 2006-07-25, Akihiro MOTOKI, Catch up to LDP v2.34
 .\"
-.TH OFFSETOF 3 2008-07-12 "GNU" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH Ì¾Á°
-.\"O offsetof \- offset of a structure member
-offsetof \- ¹½Â¤ÂΤΥá¥ó¥Ð¡¼¤Î¥ª¥Õ¥»¥Ã¥È¤òÊÖ¤¹
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
+.TH OFFSETOF 3 2014\-04\-06 GNU "Linux Programmer's Manual"
+.SH 名前
+offsetof \- 構造体のメンバーのオフセットを返す
+.SH 書式
 .nf
-.B #include <stddef.h>
+\fB#include <stddef.h>\fP
 .sp
-.BI "size_t offsetof(" type ", " member );
+\fBsize_t offsetof(\fP\fItype\fP\fB, \fP\fImember\fP\fB);\fP
 .fi
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O The macro
-.\"O .BR offsetof ()
-.\"O returns the offset of the field
-.\"O \fImember\fP from the start of the structure \fItype\fP.
-.BR offsetof ()
-¥Þ¥¯¥í¤Ï¡¢¥Õ¥£¡¼¥ë¥É \fImember\fP ¤Î
-¹½Â¤ÂΠ\fItype\fP ¤ÎÀèƬ¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È¤òÊÖ¤¹¡£
+.SH 説明
+\fBoffsetof\fP()  マクロは、フィールド \fImember\fP の 構造体 \fItype\fP の先頭からのオフセットを返す。
 
-.\"O This macro is useful because the sizes of the fields that compose
-.\"O a structure can vary across implementations,
-.\"O and compilers may insert different numbers of padding
-.\"O bytes between fields.
-.\"O Consequently, an element's offset is not necessarily
-.\"O given by the sum of the sizes of the previous elements.
-¤³¤Î¥Þ¥¯¥í¤¬Í­ÍѤʤΤϡ¢
-¹½Â¤ÂΤò¹½À®¤¹¤ë¥Õ¥£¡¼¥ë¥É¤Î¥µ¥¤¥º¤Ï¼ÂÁõ¤Ë¤è¤Ã¤ÆÊѲ½¤¹¤ë¤·¡¢
-¥³¥ó¥Ñ¥¤¥é¤Ë¤è¤ê¥Õ¥£¡¼¥ë¥É´Ö¤ËÁÞÆþ¤¹¤ë¥Ñ¥Ç¥£¥ó¥°¤Î¥Ð¥¤¥È¿ô¤â
-°ã¤¦²ÄǽÀ­¤¬¤¢¤ë¤«¤é¤Ç¤¢¤ë¡£
-¤½¤Î·ë²Ì¡¢¤¢¤ë¥¨¥ì¥á¥ó¥È¤Î¥ª¥Õ¥»¥Ã¥È¤Ïɬ¤º¤·¤â¤½¤ì¤è¤êÁ°¤Î
-¥¨¥ì¥á¥ó¥È¤Î¥µ¥¤¥º¤Î¹ç·×¤È¤Ï¤Ê¤é¤Ê¤¤¡£
+このマクロが有用なのは、 構造体を構成するフィールドのサイズは実装によって変化するし、 コンパイラによりフィールド間に挿入するパディングのバイト数も
+違う可能性があるからである。 その結果、あるエレメントのオフセットは必ずしもそれより前の エレメントのサイズの合計とはならない。
 
-.\"O A compiler error will result if
-.\"O \fImember\fP is not aligned to a byte boundary
-.\"O (i.e., it is a bit field).
-\fImember\fP ¤¬¥Ð¥¤¥È¶­³¦¤Ë°ÌÃÖ¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
-(¤¹¤Ê¤ï¤Á¡¢¥Ó¥Ã¥È¥Õ¥£¡¼¥ë¥É¤Î¾ì¹ç) ¤Ë¤Ï¡¢
-¥³¥ó¥Ñ¥¤¥é¤Ç¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¡£
-.\"O .SH "RETURN VALUE"
-.SH ÊÖ¤êÃÍ
-.\"O .BR offsetof ()
-.\"O returns the offset of the given
-.\"O .I member
-.\"O within the given
-.\"O .IR type ,
-.\"O in units of bytes.
-.BR offsetof ()
-¤Ï¡¢»ØÄꤵ¤ì¤¿
-.I member
-¤Î»ØÄꤵ¤ì¤¿
-.I type
-¤ÎÃæ¤Ç¤Î¥ª¥Õ¥»¥Ã¥È¤ò¡¢¥Ð¥¤¥Èñ°Ì¤ÇÊÖ¤¹¡£
-.\"O .SH "CONFORMING TO"
-.SH ½àµò
-C89, C99, POSIX.1-2001.
-.\"O .SH EXAMPLE
-.SH Îã
-.\"O On a Linux/i386 system, when compiled using the default
-.\"O .BR gcc (1)
-.\"O options, the program below produces the following output:
-Linux/i386 ¥·¥¹¥Æ¥à¤Ç¡¢
-.BR gcc (1)
-¤Î¥Ç¥Õ¥©¥ë¥È¥ª¥×¥·¥ç¥ó¤Ç
-¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¾ì¹ç¡¢²¼µ­¤Î¥×¥í¥°¥é¥à¤Ï°Ê²¼¤Î¤è¤¦¤Ê½ÐÎϤòÊÖ¤¹¡£
+\fImember\fP がバイト境界に位置していない場合 (すなわち、ビットフィールドの場合) には、 コンパイラでエラーが発生する。
+.SH 返り値
+\fBoffsetof\fP()  は、指定された \fImember\fP の指定された \fItype\fP の中でのオフセットを、バイト単位で返す。
+.SH 準拠
+C89, C99, POSIX.1\-2001.
+.SH 例
+Linux/i386 システムで、 \fBgcc\fP(1)  のデフォルトオプションで コンパイルされた場合、下記のプログラムは以下のような出力を返す。
 .in +4n
 .nf
 
-.RB "$" " ./a.out"
+$\fB ./a.out\fP
 offsets: i=0; c=4; d=8 a=16
 sizeof(struct s)=16
 .fi
-.nf
-.\"O .SS Program source
-.SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
+.SS プログラムのソース
 \&
 .nf
 #include <stddef.h>
@@ -121,16 +81,17 @@ main(void)
         char a[];
     };
 
-.\"O     /* Output is compiler dependent */
-    /* ½ÐÎϤϥ³¥ó¥Ñ¥¤¥é°Í¸¤Ç¤¢¤ë */
+    /* 出力はコンパイラ依存である */
 
-    printf("offsets: i=%ld; c=%ld; d=%ld a=%ld\\n",
-            (long) offsetof(struct s, i),
-            (long) offsetof(struct s, c),
-            (long) offsetof(struct s, d),
-            (long) offsetof(struct s, a));
-    printf("sizeof(struct s)=%ld\\n", (long) sizeof(struct s));
+    printf("offsets: i=%zd; c=%zd; d=%zd a=%zd\en",
+            offsetof(struct s, i), offsetof(struct s, c),
+            offsetof(struct s, d), offsetof(struct s, a));
+    printf("sizeof(struct s)=%zd\en", sizeof(struct s));
 
     exit(EXIT_SUCCESS);
 }
 .fi
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。