From: Jarkko Hietaniemi Date: Sat, 12 Aug 2006 10:33:38 +0000 (+0300) Subject: perlhack.pod: more portability pitfalls X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=27565cb6b0d14f9ecd5ee3593c2cb2a263020809;p=p5sagit%2Fp5-mst-13.2.git perlhack.pod: more portability pitfalls Message-Id: <200608120733.k7C7XcU0268432@kosh.hut.fi> p4raw-id: //depot/perl@28698 --- diff --git a/pod/perlhack.pod b/pod/perlhack.pod index efa3344..da616b4 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 note that not all the possible +warnings are given unless you also compile with C<-O>. + Also study L 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 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.