TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Paul Wankadia
from: Paul Edwards
date: 1996-10-13 22:49:26
subject: Auto string-length deter

FA> So sizeof() will return the length of the pointer.
PW> I seem to get 2...
PE> In small memory model you will get that.  Try compiling in large, and
PE> you'll get 4.

PW> What sort of pointers does large model use?  Far?  

Yes.

PW> Does huge model use huge pointers?

I don't know what a huge pointer is, although I can take a guess.

FA> Perhaps if the string is global it may also work, but i didn't try or
PW> What's wrong with global variables? :)
PE> Nothing more than global functions.

PW> I was told (prior to this) that global variables should be cut down as much
PW> as possible.

I was told that too.  Then I saw people (or myself, can't remember) writing
functions such as:

static int varx;

void set_variable_x(int value)
{
    varx = value;
}

int get_variable_x(void)
{
    return (varx);
}

Then I realised that it was a complete wank.  Why is get_variable_x() OK,
but x is not?  I then started using global variables freely, although that
later got replaced by PDS0004.TXT (available for FREQ from 3:711/934).  I
questioned someone giving a lecture once on something similar to structured
programming, and asked him what was wrong with global variables over global
functions, and the reaction I got was amusing.  At the end of the lecture,
he asked us what we were going to change in our methods after his lecture,
and I offered "I'm going to start using global variables".  :-) 
God I'm a menace.

PW> BTW the way you said "global functions" -- is it possible
to declare (this 
PW> is a silly question) a "local" function, accessible from
inside another 
PW> function ONLY???

No, but what you can do is declare a function that is local to the current
SOURCE file, which is perfectly fine.  You stick a "static" in
front of it.  In that context, "static" means "local". 
Presumably they ran out of keywords or something.

PW> BTW I'd rather keep the code as portable as possible (between
PE> Good to see.  You should have a bloody good reason not to make it
PE> portable, rather than the other way around.  And isolate out the

PW> When you say portable, do you mean portable between DOS compilers, or 
PW> between DOS and Unix, or usable on any platform, or what?  I have always 

Portable to ANY platform.  If you follow ISO/IEC 9899:1990, that's exactly
what you get.  If you DON'T follow the ISO standard, then you should have a
good reason, and document and isolate that code. Or else have a different
strategy in mind for when your customer says "This is a great program,
here's $50,000, go and stick it on that computer over there (the one with
67-bit longs, integers and chars).

PW> been a tad confused about that term.  BTW what non-portable functions and 
PW> stuff exist in Turbo C++ v3.0 that I should be aware of?

Billions and billions of them.  What you should do is FREQ ANSI_C.* from
3:711/934 and then use THAT as your reference INSTEAD of the Turbo C++'s
manuals.

PW> I have used #ifdef before...  BTW you seem rather knowledgeable -- if you
PW> haven't already replied about this, what EXACTLY does "extern
\"C\"" do and
PW> mean???

That's used in C++ only.  It says "all the following functions are
actually written in C".  I am not a C++ expert though, so don't quote
me.  :-)  BFN.  Paul.
@EOT:

---
* Origin: X (3:711/934.9)
SEEN-BY: 633/267 270
@PATH: 711/934 808 50/99 635/544 727 728 633/267

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™.