As soon as a structured type is introduced then byte alignment, which will change the number of bits required, will come into play. Also, never change the name of the constructor: always use Create. What you expect is true, if and only if, every field that is being packed is an ordinal type. freepascal Share Improve this question Follow edited at 16:47 asked at 16:27 mirgee 390 2 13 2 Show the code where you declare P and your initialization code. To understand pointer arithmetic, let us. Readln(filehandle, var) and Writeln(filehandle, var) are for text files. There are four arithmetic operators that can be used on pointers: increment, decrement, +, and. Therefore, you can perform arithmetic operations on a pointer just as you can on a numeric value. Andrew Brunner 14 years ago In general I use pointers to data structures and especially when they are arrays. type Rptr real Cptr char Bptr Boolean Aptr array1.5 of real date-ptr date Date record Day: 1.31 Month: 1.12 Year: 1900. Free Pascal supports pointer arithmetic as C does. It's relative complexity simply shows why dyn. Packing, and particularly btpacking, depends on the data type that is being packed. As explained in main chapter, Pascal pointer is an address, which is a numerical value stored in a word. The code as shown is standard pascal code. However, if you have 3 ordinal type fields that together use 5 bits (for example) and that is followed by a structured type, the structured type will be aligned on a byte boundary causing 3 (8 - 5) bits to be wasted due to alignment. The bitpacking is fully applied when using ordinal types. IOW, if you have array elements that when bitpacked use 2 bits each and you have 3 of those elements (for a total of 6 bits), that array is going to take one entire byte because the next bitpacked field is not allowed to be part of a structured type even when packed. If I am interpreting the compiler documentation correctly, the reason you get those results is because structured types are always aligned on a byte boundary even when they are part of a bitpacked structure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |