summaryrefslogtreecommitdiff
path: root/pod/perlhack.pod
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2006-08-12 13:33:38 +0300
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-08-12 12:53:32 +0000
commit27565cb6b0d14f9ecd5ee3593c2cb2a263020809 (patch)
tree9a0b133277647a78070c20299246a145b2ac9e2c /pod/perlhack.pod
parent3bf969c5666cc875b9f8de7ec33cabcc26d26796 (diff)
downloadperl-27565cb6b0d14f9ecd5ee3593c2cb2a263020809.tar.gz
perlhack.pod: more portability pitfalls
Message-Id: <200608120733.k7C7XcU0268432@kosh.hut.fi> p4raw-id: //depot/perl@28698
Diffstat (limited to 'pod/perlhack.pod')
-rw-r--r--pod/perlhack.pod56
1 files changed, 55 insertions, 1 deletions
diff --git a/pod/perlhack.pod b/pod/perlhack.pod
index efa3344394..da616b4e3f 100644
--- a/pod/perlhack.pod
+++ b/pod/perlhack.pod
@@ -2474,6 +2474,9 @@ incompatibilities in your system's header files.)
Use the Configure C<-Dgccansipedantic> flag to enable the gcc
C<-ansi -pedantic> flags which enforce stricter ANSI rules.
+If using the C<gcc -Wall> note that not all the possible
+warnings are given unless you also compile with C<-O>.
+
Also study L<perlport> carefully to avoid any bad assumptions
about the operating system, filesystem, and so forth.
@@ -2544,7 +2547,43 @@ Lvalue casts
(int)*p = ...;
Simply not portable. Get your lvalue to be of the right type,
-or maybe use temporary variables.
+or maybe use temporary variables, or dirty tricks with unions.
+
+=item *
+
+Assume B<anything> about structs
+
+=over 8
+
+=item *
+
+That a certain field exists in a struct
+
+=item *
+
+That no other fields exist besides the ones you know of know of
+
+=item *
+
+That a field is a certain signedness, sizeof, or type
+
+=item *
+
+That the fields are in a certain order
+
+=item *
+
+That the sizeof(struct) is the same everywhere
+
+=item *
+
+That there is no padding between the fields
+
+=item *
+
+That there are no alignment requirements for the fields
+
+=back
=item *
@@ -2585,6 +2624,21 @@ The gcc option C<-Wendif-labels> warns about the bad variant
=item *
+Having a comma after the last element of an enum list
+
+ enum color {
+ CERULEAN,
+ CHARTREUSE,
+ CINNABAR, /* Right here. */
+ };
+
+is not portable. Leave out the last comma.
+
+Also note that whether enums are implicitly morphable to ints
+varies between compilers, you might need to (int).
+
+=item *
+
Using //-comments
// This function bamfoodles the zorklator.