aboutsummaryrefslogtreecommitdiffstats
path: root/alignment.c
diff options
context:
space:
mode:
authorEliteTK <tomasz.kramkowski@gmail.com>2015-02-12 00:24:07 +0000
committerEliteTK <tomasz.kramkowski@gmail.com>2015-02-12 00:24:07 +0000
commit35e4f1939645be6673cad3b49290c91946cad599 (patch)
tree21d707283ba79071df3bf03b9892100ec7139f01 /alignment.c
parent266783815ee3ed13d4cec48fc0a3fec14aa52c4d (diff)
downloadc-stuff-35e4f1939645be6673cad3b49290c91946cad599.tar.gz
c-stuff-35e4f1939645be6673cad3b49290c91946cad599.tar.xz
c-stuff-35e4f1939645be6673cad3b49290c91946cad599.zip
alignment.c
Diffstat (limited to 'alignment.c')
-rw-r--r--alignment.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/alignment.c b/alignment.c
new file mode 100644
index 0000000..bf745ee
--- /dev/null
+++ b/alignment.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2015 Tomasz Kramkowski <tk@the-tk.com>
+ *
+ * This program is free software. It is licensed under version 3 of the
+ * GNU General Public License.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see [http://www.gnu.org/licenses/].
+ */
+#include <stdio.h>
+#include <stdlib.h>
+
+struct misaligned {
+ char ca;
+ long la;
+
+ char cb;
+ long lb;
+
+ char cc;
+ long lc;
+
+ char cd;
+ long ld;
+
+ char ce;
+ long le;
+
+ char cf;
+ long lf;
+
+ char cg;
+ long lg;
+
+ char ch;
+ long lh;
+};
+
+struct aligned {
+ char ca;
+ char cb;
+ char cc;
+ char cd;
+ char ce;
+ char cf;
+ char cg;
+ char ch;
+
+ long la;
+ long lb;
+ long lc;
+ long ld;
+ long le;
+ long lf;
+ long lg;
+ long lh;
+};
+
+int main(void)
+{
+ printf("sizeof misaligned: %d, sizeof aligned %d\n", sizeof(struct
+ misaligned), sizeof(struct aligned));
+
+ return EXIT_SUCCESS;
+}