[fpc-pascal] Help converting C code

Michael Van Canneyt michael at freepascal.org
Wed Feb 3 08:59:33 CET 2010



On Tue, 2 Feb 2010, leledumbo wrote:

>
> Does the BlockRead below:
>
> type
>  TRGBQuad = record
>    rgbBlue: GLubyte;
>    rgbGreen: GLubyte;
>    rgbRed: GLubyte;
>    rgbReserved: GLubyte;
>  end;
>
> ...
>
> var
>  FileHandle: File;
>  BytesRead: GLuint;
>  FColorPalette: PRGBQuad;
>  NumberOfColours: GLuint;
>
> ...
>
> BlockRead(FileHandle,FColorPalette^,SizeOf(TRQBQuad)*NumberOfColours,BytesRead);
>
> corresponds to this C code:
>
> typedef struct tagRGBQuad {
>  char rgbBlue;
>  char rgbGreen;
>  char rgbRed;
>  char rgbReserved;
> } RGBQuad;
>
> ...
>
> RGBQuad *colours;
> FILE *in;
> int numColours;
>
> ...
>
> fread(colours,sizeof(RGBQuad),numColours,in);
>

Yes, if GLubyte=char

Michael.



More information about the fpc-pascal mailing list