passing pointers, GPC documentation

Sun, 27 Apr 1997 20:06:45 +0200 (MET DST)


According to skye:
>
> Yes, I can get that to work but what still fails is when gBuffer is
> allocated using new():
> [...]
> 	ScreenBlit( gBuffer); (* crashes in the movedata() from the std C lib *)

Again:  How did you declare the "ScreenBlit" procedure?

> Now I'm not too sure how memory allocation works under pascal. Is this
> right? I don't have many examples to got from and they all work something
> like this. would this be the same as this in C:
> 
> char* gBuffer;
> gBuffer = malloc(320*200);
> free(gBuffer);      

Yes.

> now I haven't seen GetMem before. The examples I'm using just use the
> method i've shown above. Does GetMem work like malloc() where I can specify
> the amount at runtime? (this would be nice).

Yes.  `GetMem' is a Borland Pascal extension:

    GetMem ( gBuffer, 320 * 200 );
    FreeMem ( gBuffer, 320 * 200 );

GPC also allows the following:

    gBuffer:= GetMem ( 320 * 200 );
    FreeMem ( gBuffer );             (* 2. parameter is optional in GPC *)

> Also, isn't there a limit to the amount of static variable memory I can use
> (DS)?

No.

> I don't want to have to fidle with my compiler options to increase
> it. If I have a static array that is 64k there is potental for probles way
> down the road, esp. if I have other large static structres.

Feel free to allocate static structures of 1MB or above.  This is one
reason why I am using GPC rather than BP for scientific programs.  (-:

> Sorry about the basic Pascal questions. It is strange switching from C/C++
> to Pascal without documentation. I keep trying to do something one way and
> find out after much frustration that is done another in Pascal. I have only
> a few Pascal DOCS I have found online and they all use TP. Are there any
> using GPC?

AFAIK, the only existing GPC documentation is our info documentation and the
GPC FAQ.  You can find both in your GPC distribution, or online at

    http://home.pages.de/~GNU-Pascal/gpc-doc.html

    http://home.pages.de/~GNU-Pascal/gpc-faq.html

If anybody wants to help to create more documentation, I suggest the
following:

    Collect all this information from this list, e.g. the `GetMem'
    stuff above, put it into a reasonable structure, and add it to the
    GNU Texinfo documentation.  If you have any questions, be sure that
    I will help you.

Like this, the reference will be made available as on-line help, e.g.
with Ctrl+F1 when using the RHIDE.

I am starting to do this *now* by writing something about Integer types.
It is appended below, so you have an example what I am speaking of and
would like to recieve.  If you have more ideas, e.g. to write something
about `writeln', just do it and post it here!

Greetings,

    Peter

  Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
 maintainer GNU Pascal [970420] - http://home.pages.de/~gnu-pascal/ [970125]

8< ---------------------------------------------------------------------------

@node Integer
@subsection Integer
@cindex Integer types

GNU Pascal supports the following Integer types:

@table @samp
  @item ByteInt
  signed 8-bit integer type, @samp{-128..128}
  @item Byte
  unsigned 8-bit integer type, @samp{0..255}
  @item ShortInt
  signed 16-bit integer type, @samp{-32768..32767}
  @item ShortWord
  unsigned 16-bit integer type, @samp{0..65535}
  @item Integer
  signed 32-bit integer type, @samp{-2147483648..2147483647}
  @item Word
  unsigned 32-bit integer type, @samp{0..4294967295}
  @item LongInt
  signed 64-bit integer type, @samp{-9223372036854775808..9223372036854775807}
  @item LongWord
  unsigned 64-bit integer type, @samp{0..18446744073709551615}
@end table

ISO Pascal defines only @samp{Integer}; the other types are GNU extensions.

Some of these types (@samp{Byte}, @samp{ShortInt}, @samp{Word},
and @samp{LongInt}) are available in Borland Pascal, too, but have a
different size there.

For sake of compatibility to Borland Pascal, @samp{LongInt} can also be
called @samp{Comp}.

On the i386 processor family, operations with @samp{Integer} usually work
faster than operations with shorter integer types like @samp{ShortInt} or
@samp{ByteInt}.

@strong{Known bug:} At the moment, GPC's run time library is not able to
@samp{write} or @samp{writeln} integer types longer than @samp{Integer}.

@c ----------------------------------------------------------------------------

@node LongInt
@subsection LongInt

@samp{LongInt} is GPC's signed 64-bit integer type,
@samp{-9223372036854775808..9223372036854775807}.  For sake of
compatibility to Borland Pascal, @samp{LongInt} can also be called
@samp{Comp}.

@xref{Integer}
@xref{LongWord}
@xref{Comp}

@c ----------------------------------------------------------------------------

@node LongWord
@subsection LongWord

@samp{ByteInt} is GPC's unsigned unsigned 64-bit integer type,
@samp{0..18446744073709551615}.

@xref{Integer}
@xref{LongInt}

@c ============================================================================


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es