From Jeff Siegel · 1996-04-05 16:49 · #73620 in EMULATE
DM>Hello Jeff!
DM>05 Apr 96 01:15, Jeff Siegel wrote to All:
DM> JS> Hi, I'm learing c++ and was wondering what the 'extern' command
DM> JS> does. The Watcom c++ 10.5 help files don't really say anything
DM> JS> about it. Also I am trying to compile a .c file I found on the
DM>This is a base command of C. What it basically means are the following:
DM>A) in all modules, the following item may not actually be in this C file, bu
DM>will definately be there at link time
DM>B) in C++, if the item is *also* defined later on, it means that this item
DM>will be available to other modules.
DM>For example:
DM>myhead.h:
DM>extern int i; // this means that you can use a global variable 'i' as an int
DM> // and that it will be available when you link.
DM>void foo(); // the extern is implied for functions
DM>file1.c:
DM>#include "myhead.h"
DM>int i; // we have to actually have it somewhere...
DM>void foo()
DM>{
DM> i = 5;
DM>}
DM>file2.c:
DM>#include "myhead.h"
DM>void bar()
DM>{
DM> cout << i << endl;
DM>}
DM>int main()
DM>{
DM> foo();
DM> bar();
DM> return 0;
DM>}
DM>Running this would print '5'.
DM>In file2.c, when you include "myhead.h", it brings the line 'extern int i'
DM>into the source, and the compiler recognizes that 'i' will be there later.
DM>file1.c, the compiler also notices that you define 'i' (using 'int i') and s
DM>it creates room for the variablee 'i' in that module.
DM>If all this confuses the HECK out of you, it's because I'm writing this at
DM>2:20 AM... :-) In that case, ask your sysop (Gerry) to give you my BBS numb
DM>(from the nodelist), and you can call my system. :-)
DM> JS> net and the compiler can't reconize a command calle 'getvert'
DM> JS> what does this do and how can I get it working with Watcom c++?
DM>That one I don't recognize...
DM>Darin McBride
DM>--- GoldED/2 2.42.G0614
DM> * Origin: Tanktalus' Tower BBS/RPGs Galore! (1:342/5015)
Sorry, the command is not 'getvert' it's 'getvect' and I found it in a
file called mouse.c, the file that get's the mouse ready for the
program.
--- MajorBBS v6.25
* Origin: C+Net BBS * Edmonton, AB Canada * 403-477-9545 (1:342/1017)