c/pascal compiler differences

Discussion in 'C Programming' started by Skybuck Flying, Aug 22, 2004.

  1. Hi,

    I think I understand now a bit better what the difference is between a c
    compiler and a pascal compiler.

    For example:

    When compiling source code with a pascal compiler. The pascal compiler will
    simply stop when it is missing an implementation for a procedure or
    whatever.

    The c compiler however will simply continue compiling even if the
    implementation for the headers/prototypes are missing.

    The c linker will then report a big list of link errors.

    Both methods have benefits and drawbacks. The pascal compiler is more
    simple... it allows one to simply proceed from error to error until it
    completely compiles and links.

    The drawback of the c compiler might be the suspended error reporting...
    it's a bit wacky... since one can not jump to the location where the stuff
    is missing ?

    or maybe one can... it's a bit wacky...

    Though I can clearly see a benefit for a c compiler since it simply compiles
    even though the implementation is completely missing.

    One could later even make different implementations and simple re-use the
    already compiled stuff and link against it.

    So one can end up linking different kind of stuff against the same compiled
    C file.

    I think this is correct though I never really tried it.

    Are there any good examples where this C/link freedom is used ?

    Does a pascal compiler have the same link freedom ? ( meaning prototype
    available but implementation missing )

    I think not... ?

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 22, 2004
    #1
    1. Advertising

  2. "Skybuck Flying" <> wrote in message
    news:cga2mq$tt0$1.nb.home.nl...

    > I think I understand now a bit better what the difference is between a
    > c compiler and a pascal compiler.
    >
    > For example:
    >
    > When compiling source code with a pascal compiler. The pascal compiler
    > will simply stop when it is missing an implementation for a procedure
    > or whatever.
    >
    > The c compiler however will simply continue compiling even if the
    > implementation for the headers/prototypes are missing.


    Pascal was specifically designed to allow one-pass compilation. So
    whenever something is missing, that's an instant error. C, also by
    design, is much looser. You can put a "void writeln();" pretty much
    anywhere in your code, and there is no error until you try to link
    together an executable that doesn't have a writeln procedure somewhere.
    There's a keyword "extern", but it may be omitted.

    Groetjes,
    Maarten Wiltink
     
    Maarten Wiltink, Aug 22, 2004
    #2
    1. Advertising

  3. Skybuck Flying

    CBFalconer Guest

    Skybuck Flying wrote:
    >
    > I think I understand now a bit better what the difference is
    > between a c compiler and a pascal compiler.


    .... snip gross misconceptions ...

    The fundamental difference is the source language. Anything else
    is a frill. c.l.c deals solely with the language, and not the
    compilers. The languages are defined by the ISO standards.

    BTW, Pascal is always capitalized.

    --
    fix (vb.): 1. to paper over, obscure, hide from public view; 2.
    to work around, in a way that produces unintended consequences
    that are worse than the original problem. Usage: "Windows ME
    fixes many of the shortcomings of Windows 98 SE". - Hutchison
     
    CBFalconer, Aug 22, 2004
    #3
  4. > When compiling source code with a pascal compiler. The pascal compiler will
    > simply stop when it is missing an implementation for a procedure or
    > whatever.
    >
    > The c compiler however will simply continue compiling even if the
    > implementation for the headers/prototypes are missing.
    >
    > The c linker will then report a big list of link errors.


    C got two stages of compiling, compilation and linking. Pascal doesn't
    use linking (here it is a part of the normal compilation). In C it is
    not a compilation error if an implementation of a method/variable is
    missing; it is a linker error. In Pascal it is a compiler error as it
    links while compiling.

    Of course you can make a program with a button which, on clicking,
    will run "MyMethod()" which is defined in "blah.h" but missing the
    implementation. You can then compile ten different object files with
    ten different implementations of MyMethod(), then link them into ten
    different programs with ten different things happening when you click
    the button.

    But you can do that same thing in Pascal, make your onclick run
    MyProcedure(), make ten different MyProcedure() implementations, then
    add one of them to your uses. Generates the same as the C linker. It
    will compile the whole thing everytime (unlike C where only the linker
    is run), but in Pascal you can actually have all ten implementations
    of MyProcedure() in the same project ;)
     
    Nicolai Hansen, Aug 23, 2004
    #4
  5. "Skybuck Flying" <> wrote in message
    news:cga2mq$tt0$1.nb.home.nl...

    > Does a pascal compiler have the same link freedom ? ( meaning prototype
    > available but implementation missing )
    >
    > I think not... ?


    As usual you think wrong. See the External Declarations entry in the Delphi
    help. Pay particular attention to the $LINK compiler directive.
     
    Bruce Roberts, Aug 23, 2004
    #5
  6. "Bruce Roberts" <> wrote in message
    news:xxmWc.7965$...
    >
    > "Skybuck Flying" <> wrote in message
    > news:cga2mq$tt0$1.nb.home.nl...
    >
    > > Does a pascal compiler have the same link freedom ? ( meaning prototype
    > > available but implementation missing )
    > >
    > > I think not... ?

    >
    > As usual you think wrong. See the External Declarations entry in the

    Delphi
    > help. Pay particular attention to the $LINK compiler directive.


    When is it linked into it ?

    Occurding to some posts... compiling and linking is the same thing in
    pascal.

    So it's actually linked in at compile time... that would be my guess.

    That's still fundamentally different than C ;)

    Unless I am mistaking :D
     
    Skybuck Flying, Aug 23, 2004
    #6
  7. Skybuck Flying

    Flash Gordon Guest

    On Mon, 23 Aug 2004 17:02:47 +0200
    "Skybuck Flying" <> wrote:

    >
    > "Bruce Roberts" <> wrote in message
    > news:xxmWc.7965$...
    > >
    > > "Skybuck Flying" <> wrote in message
    > > news:cga2mq$tt0$1.nb.home.nl...
    > >
    > > > Does a pascal compiler have the same link freedom ? ( meaning
    > > > prototype available but implementation missing )
    > > >
    > > > I think not... ?

    > >
    > > As usual you think wrong. See the External Declarations entry in the

    > Delphi
    > > help. Pay particular attention to the $LINK compiler directive.

    >
    > When is it linked into it ?
    >
    > Occurding to some posts... compiling and linking is the same thing in
    > pascal.
    >
    > So it's actually linked in at compile time... that would be my guess.
    >
    > That's still fundamentally different than C ;)
    >
    > Unless I am mistaking :D


    It all depends on WHICH Pascal variant you are talking about. I've used
    versions of Pascal where the Linking was done at run time.

    The original Pascal definition did not support separately compiled
    modules so there was not much linking to be done. Later extensions added
    separate compilation of modules at which point linkers became involved
    and worked basically the same as they do for C. However, the language
    definition still included (and probably still does) a requirement to
    declare before first use, something the original C did not (I can't
    remember if C99 has added that but some compilers provide it as an
    extension). To allow for things like mutually recursive functions Pascal
    included a forward declaration which gives the compiler the signature of
    the function and tells it to resolve it further down the file.

    Also, whilst Pascal and C are very different languages in many respects
    there are implementations which provide mechanisms for linking C code
    and Pascal code, so the linkage requirements of the languages can't be
    mutually incompatible. However, the method for linking the two languages
    is off topic for this group. :)
    --
    Flash Gordon
    Sometimes I think shooting would be far too good for some people.
    Although my email address says spam, it is real and I read it.
     
    Flash Gordon, Aug 23, 2004
    #7
  8. "Skybuck Flying" <> wrote in message
    news:cgd0h6$aha$1.nb.home.nl...

    > Occurding to some posts... compiling and linking is the same thing in
    > pascal.
    >
    > So it's actually linked in at compile time... that would be my guess.
    >
    > That's still fundamentally different than C ;)


    Delphi first compiles units then it links the project. If all units are
    up-to-date, essentially the only thing that happens is the linking.
     
    Bruce Roberts, Aug 23, 2004
    #8
  9. Skybuck Flying

    Xenos Guest

    "Bruce Roberts" <> wrote in message
    news:xxmWc.7965$...
    >
    > "Skybuck Flying" <> wrote in message
    > news:cga2mq$tt0$1.nb.home.nl...
    >
    > > Does a pascal compiler have the same link freedom ? ( meaning prototype
    > > available but implementation missing )
    > >
    > > I think not... ?

    >
    > As usual you think wrong. See the External Declarations entry in the

    Delphi
    > help. Pay particular attention to the $LINK compiler directive.
    >
    >

    That Delphi, not standard Pascal.
     
    Xenos, Aug 23, 2004
    #9
  10. "Skybuck Flying" <> wrote in message
    news:cgd0h6$aha$1.nb.home.nl...
    [...]
    > Occurding to some posts... compiling and linking is the same thing in
    > pascal.


    D-C-U.

    Groetjes,
    Maarten Wiltink
     
    Maarten Wiltink, Aug 23, 2004
    #10
  11. "Bruce Roberts" <> wrote in message
    news:8ApWc.8357$...
    >
    > "Skybuck Flying" <> wrote in message
    > news:cgd0h6$aha$1.nb.home.nl...
    >
    > > Occurding to some posts... compiling and linking is the same thing in
    > > pascal.
    > >
    > > So it's actually linked in at compile time... that would be my guess.
    > >
    > > That's still fundamentally different than C ;)

    >
    > Delphi first compiles units then it links the project. If all units are
    > up-to-date, essentially the only thing that happens is the linking.
    >


    Ok, let's take it to the test:

    procedure unimplemented;

    begin

    unimplemeted;

    end.

    void unimplemented();

    int main()
    {

    unimplemented();

    }

    Without actually having given ;) it a try I think the delphi/pascal example
    won't even compile :) and the C version will just like that :D

    Is there a way to make the pascal example compile and then later link
    different files to it ? ( I think not ? )

    The difference is: I could distribute my compiled C program to anybody...
    and tell them to simply implement a few function and link it and suprise
    suprise it would actually work :D

    Lol, I think pascal/delphi will be another story !

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 23, 2004
    #11
  12. "Skybuck Flying" <> wrote in message
    news:cgddeu$rqe$1.nb.home.nl...

    > Ok, let's take it to the test:


    > Without actually having given ;) it a try I think the delphi/pascal

    example
    > won't even compile :) and the C version will just like that :D


    It helps to read the documentation. I gave you a specific reference, if you
    had read it you would see that, with the correct syntax, your Delphi would
    have compiled just fine.
     
    Bruce Roberts, Aug 23, 2004
    #12
  13. Skybuck Flying

    Flash Gordon Guest

    On Mon, 23 Aug 2004 13:00:10 -0400
    "Xenos" <> wrote:

    >
    > "Bruce Roberts" <> wrote in message
    > news:xxmWc.7965$...
    > >
    > > "Skybuck Flying" <> wrote in message
    > > news:cga2mq$tt0$1.nb.home.nl...
    > >
    > > > Does a pascal compiler have the same link freedom ? ( meaning
    > > > prototype available but implementation missing )
    > > >
    > > > I think not... ?

    > >
    > > As usual you think wrong. See the External Declarations entry in the

    > Delphi
    > > help. Pay particular attention to the $LINK compiler directive.
    > >

    > That Delphi, not standard Pascal.


    Similar things apply to every Pascal implementation I have used, and
    that is quite a few. I believe that ISO standard Pascal also supports
    separate compilation of modules.
    --
    Flash Gordon
    Sometimes I think shooting would be far too good for some people.
    Although my email address says spam, it is real and I read it.
     
    Flash Gordon, Aug 23, 2004
    #13
  14. "Bruce Roberts" <> wrote in message
    news:kerWc.8453$...
    >
    > "Skybuck Flying" <> wrote in message
    > news:cgddeu$rqe$1.nb.home.nl...
    >
    > > Ok, let's take it to the test:

    >
    > > Without actually having given ;) it a try I think the delphi/pascal

    > example
    > > won't even compile :) and the C version will just like that :D

    >
    > It helps to read the documentation. I gave you a specific reference, if

    you

    Huh ? What reference ? :) No you didn't :)

    > had read it you would see that, with the correct syntax, your Delphi would
    > have compiled just fine.
    >
    >
     
    Skybuck Flying, Aug 24, 2004
    #14
  15. "Skybuck Flying" <> wrote in message
    news:cgf5n2$fk3$1.nb.home.nl...
    > "Bruce Roberts" <> wrote in message
    > news:kerWc.8453$...


    >> It helps to read the documentation. I gave you a specific reference,


    > Huh ? What reference ? :) No you didn't :)


    "See the External Declarations entry in the Delphi help. Pay particular
    attention to the $LINK compiler directive."

    My baby nieces have a longer attention span, and they listen better, too.

    Groetjes,
    Maarten Wiltink
     
    Maarten Wiltink, Aug 24, 2004
    #15
  16. "Maarten Wiltink" <> wrote in message
    news:412b25ec$0$43451$4all.nl...
    > "Skybuck Flying" <> wrote in message
    > news:cgf5n2$fk3$1.nb.home.nl...
    > > "Bruce Roberts" <> wrote in message
    > > news:kerWc.8453$...

    >
    > >> It helps to read the documentation. I gave you a specific reference,

    >
    > > Huh ? What reference ? :) No you didn't :)

    >
    > "See the External Declarations entry in the Delphi help. Pay particular
    > attention to the $LINK compiler directive."
    >
    > My baby nieces have a longer attention span, and they listen better, too.


    Dude, really, I already know that part of the help file, you're boring me :D

    $LINK directive is boring :D
     
    Skybuck Flying, Aug 24, 2004
    #16
  17. "Skybuck Flying" <> wrote in message
    news:cggg7h$970$1.nb.home.nl...
    > "Maarten Wiltink" <> wrote in message
    > news:412b25ec$0$43451$4all.nl...
    >> "Skybuck Flying" <> wrote in message
    >> news:cgf5n2$fk3$1.nb.home.nl...
    >>> "Bruce Roberts" <> wrote in message
    >>> news:kerWc.8453$...


    >>>> It helps to read the documentation. I gave you a specific reference,

    >>
    >>> Huh ? What reference ? :) No you didn't :)

    >>
    >> "See the External Declarations entry in the Delphi help. Pay particular
    >> attention to the $LINK compiler directive."
    >>
    >> My baby nieces have a longer attention span, and they listen better, too.

    >
    > Dude, really, I already know that part of the help file, you're boring
    > me :D
    >
    > $LINK directive is boring :D


    "Dude", "really", the question wasn't if you had already read it. It was
    if you were spouting nonsense or not when you claimed he didn't give you
    a reference. Stop taking those pills from the spam ad and go back to the
    ones the doctor gave you.

    Groetjes,
    Maarten Wiltink
     
    Maarten Wiltink, Aug 25, 2004
    #17
  18. "Maarten Wiltink" <> wrote in message
    news:412c3887$0$36860$4all.nl...
    > "Skybuck Flying" <> wrote in message
    > news:cggg7h$970$1.nb.home.nl...
    > > "Maarten Wiltink" <> wrote in message
    > > news:412b25ec$0$43451$4all.nl...
    > >> "Skybuck Flying" <> wrote in message
    > >> news:cgf5n2$fk3$1.nb.home.nl...
    > >>> "Bruce Roberts" <> wrote in message
    > >>> news:kerWc.8453$...

    >
    > >>>> It helps to read the documentation. I gave you a specific reference,
    > >>
    > >>> Huh ? What reference ? :) No you didn't :)
    > >>
    > >> "See the External Declarations entry in the Delphi help. Pay particular
    > >> attention to the $LINK compiler directive."
    > >>
    > >> My baby nieces have a longer attention span, and they listen better,

    too.
    > >
    > > Dude, really, I already know that part of the help file, you're boring
    > > me :D
    > >
    > > $LINK directive is boring :D

    >
    > "Dude", "really", the question wasn't if you had already read it. It was
    > if you were spouting nonsense or not when you claimed he didn't give you
    > a reference. Stop taking those pills from the spam ad and go back to the
    > ones the doctor gave you.


    The whole point ofcourse is that in C one doesn't need any link directives ?

    Or maybe unless one counts the link directives in visual c's project file :D
     
    Skybuck Flying, Aug 25, 2004
    #18
  19. > As usual you think wrong. See the External Declarations entry in the Delphi
    > help. Pay particular attention to the $LINK compiler directive.


    AFAIK (and as far as I could read from the help files :p) $LINK
    doesn't do anything but link to a non-project file (and as the help
    file says, to use with files of other languages, ie .o/.obj C files/VB
    files).

    The C compiler allows you to generate a kind of "open ended" file (the
    object file) which is compiled but not linked. For example a file
    called test.c

    void MyMethod();

    int main()
    {
    MyMethod();

    return 0;
    }

    This will compile, this will generate an object file, but this will
    not generate an executable. It will say something like "LINKER ERROR:
    unsatisfied external "void MyMethod()" in file test.c".
    At a later time you can then make a file test2.c

    void MyMethod()
    {
    return;
    }

    compile this file, and link test.o with test2.o and generate test.exe.
    Useful? ;-)

    /Nic
     
    Nicolai Hansen, Aug 25, 2004
    #19
  20. "Nicolai Hansen" <> wrote in message
    news:...
    > > As usual you think wrong. See the External Declarations entry in the

    Delphi
    > > help. Pay particular attention to the $LINK compiler directive.

    >
    > AFAIK (and as far as I could read from the help files :p) $LINK
    > doesn't do anything but link to a non-project file (and as the help
    > file says, to use with files of other languages, ie .o/.obj C files/VB
    > files).
    >
    > The C compiler allows you to generate a kind of "open ended" file (the
    > object file) which is compiled but not linked. For example a file
    > called test.c
    >
    > void MyMethod();
    >
    > int main()
    > {
    > MyMethod();
    >
    > return 0;
    > }
    >
    > This will compile, this will generate an object file, but this will
    > not generate an executable. It will say something like "LINKER ERROR:
    > unsatisfied external "void MyMethod()" in file test.c".
    > At a later time you can then make a file test2.c
    >
    > void MyMethod()
    > {
    > return;
    > }
    >
    > compile this file, and link test.o with test2.o and generate test.exe.
    > Useful? ;-)


    If it's usefull I don't know =D

    But it is interesting :D

    >
    > /Nic
     
    Skybuck Flying, Aug 25, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hans-Marc Olsen
    Replies:
    4
    Views:
    3,070
    Jacek Dziedzic
    Nov 19, 2004
  2. Caleb Hattingh
    Replies:
    2
    Views:
    608
    Caleb Hattingh
    Mar 16, 2006
  3. Home_Job_opportunity
    Replies:
    0
    Views:
    515
    Home_Job_opportunity
    Jan 8, 2009
  4. Home_Job_opportunity
    Replies:
    0
    Views:
    602
    Home_Job_opportunity
    Jan 14, 2009
  5. Merciadri Luca
    Replies:
    5
    Views:
    1,103
    Merciadri Luca
    Oct 14, 2010
Loading...

Share This Page