Recent

Author Topic: The problem of Pascal development  (Read 31766 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: The problem of Pascal development
« Reply #30 on: March 23, 2011, 12:48:43 pm »
Well I still did not learn C++ (next year it will be teached to me), but AFAIK, in C++ they have a .h file and a .c file while we Pascaline guys have only a .pas file where everything is included.
As I understood the C++ guys have these section in the .h file:
program
const
var
interface
bla bla

while their begin and end section is in the .c file.

But I can be totally wrong ;-)

Afaik no. They pretty much only have TYPEs and pure constants (#define, so no complex constants that have an own address)

While variables and other bits that occupy memory might be visible in the header, they are essentailly only forward declarations.  This is because the header must be includable multiple times and not lead to multiple instances of the variables.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: The problem of Pascal development
« Reply #31 on: March 23, 2011, 07:10:07 pm »
Quote
While variables and other bits that occupy memory might be visible in the header, they are essentailly only forward declarations.
Umm... since when variable declaration can be forwarded? external-ed is possible, but forwarded...
Quote
This is because the header must be includable multiple times and not lead to multiple instances of the variables.
That's what I mean by getting multiple defined symbols error at link time (which will NEVER occur in Pascal unless you use externals and aliases).

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: The problem of Pascal development
« Reply #32 on: March 25, 2011, 11:37:14 am »
Quote
While variables and other bits that occupy memory might be visible in the header, they are essentailly only forward declarations.

It is external when you compile program.c using unit.h.   But when you compile unit.c with unit.h, afaik since ISO C (not K&R) these declarations are checked, which is more forward style.

The point is that however you want to view it (which depends on context), the header versions don't allocate memory ;-)

 

TinyPortal © 2005-2018