delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/18/04:17:20

Message-ID: <35D935FA.BB5E1E88@geocities.com>
From: Merlin <merlin__ AT geocities DOT com>
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: A very basic question about C programming... diary of a newbie Part 1
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980812131004 DOT 17366A-100000 AT is> <35D2A017 DOT 4808178C AT geocities DOT com> <35d30896 DOT 834512 AT news DOT Austria DOT EU DOT net> <35D3BC2B DOT 5F92B357 AT geocities DOT com> <35d3ef05 DOT 75223464 AT news DOT snafu DOT de> <35D664E8 DOT EB0CEA0C AT geocities DOT com> <35d8a9fe DOT 9175287 AT news DOT Austria DOT EU DOT net> <35D7CDA3 DOT 2138B40B AT geocities DOT com> <35d92222 DOT 866292 AT news DOT Austria DOT EU DOT net>
Lines: 42
Date: Tue, 18 Aug 1998 08:08:56 GMT
NNTP-Posting-Host: 187-cy-wpg.ilos.net
NNTP-Posting-Date: Tue, 18 Aug 1998 03:08:56 CDT
Organization: MBnet Networking Inc.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Gerhard Gruber wrote:

> Destination: Merlin <merlin__ AT geocities DOT com>
> From: Gruber Gerhard
> Group: comp.os.msdos.djgpp
> Date: Mon, 17 Aug 1998 06:32:21 GMT:
>
> >> >well....i suppose it would be silly not to include that one word and risk a mistake
> >> >but...If you passed parameters to the function prototyped without the void...it
> >> >wouldn't screw up the program. It simply would ingnore the parameters wouldn't it?...
> >> >or would it?
> >>
> >> No it would not. In C++ the compiler should issue a warning (or an error?) and
> >> in C it is correctly passed on. If you are calling a function with pascal
> >> convention, though, it would crash because in pascal the called function is
> >> cleaning up the stack.
> >
> >ahh..so if i left out the void and passed a parameter could i use that parameter without
> >without having ever prototyped it?
>
> That's it. Now we got it. :) But that seems to be only the case with C. In C++
> the compiler seems to assume void anyway.
>
> >and what do you mean by pascal convention?
>
> I don't know if DJGPP supports pascal style calling, but in C the arguments
> are pushed on the stack and taken from the stack by the caller. In pascal the
> arguments are pushed on the stack by the caller and removed from the stack by
> the callee. This means that, if you pass the wrong number of parameters (to
> much) to a C function, then nothing happens (if you pass to less then you
> might get problems). If you pass to much arguments to a pascal function then
> the stack is damaged. This is only of interest if you have to interface to
> pascal functions (i.e in windows programming this is needed).

ahhh...so in the end all this could cause a stack overflow..that is assuming it doesn't stop
when you screw the stack up...

L8r,
   Merlin.



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019