| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Pascal - C |
-= Pete Replied to steven pasztor about: Pascal -> C =-
G'day steven
PE> Ah, this one is not possible, at least with C. However, you may
PE> get what you really want, by using separate source files, and
PE> making the functions in them "static", ie internal-visibility
PE> only.
sp> Hmmm...? I must claim ignorance of such things... How is it
sp> done and what does it do?
Just create a source file and any functions you want to remain private
you prefix with 'static' see below, btw this is only off the top of my
head so it's untested.
******* sheep.c *************
int flocksize(int sheepdogs);
static int countsheep(void);
int flocksize(int sheepdogs) {
return countsheep() * sheepdogs;
}
/* local helper function */
static int countsheep(void) {
int sheep = 0;
while(!asleep)
sheep++;
return sheep;
}
******** end sheep.c **********
******** main.c *********
#include
extern int flocksize(int sheepdogs);
extern int countsheep(void);
int main(void) {
int sheep, dogs = 4;
sheep = flocksize(dogs);
/* this should generate an error */
if(countsheep())
printf("get to bloody sleep\n");
return 0;
}
******** end main.c *************
-=Pete=-
--- OMX/Blue Wave v2.12
* Origin: Gates of Hell (3:713/914.16)SEEN-BY: 50/99 78/0 620/243 623/630 711/401 409 410 413 430 808 809 932 934 SEEN-BY: 712/508 515 713/111 317 601 611 615 618 700 826 888 914 714/906 SEEN-BY: 800/1 7877/2809 @PATH: 713/914 615 888 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.