GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Dec-2004, 00:12
Poolan Poolan is offline
New Member
 
Join Date: Oct 2004
Posts: 19
Poolan is on a distinguished road

Is keyword extern is an ulternate for #include


Is keyword extern is an ulternate for #include?

Or is it possible for me to use a.c file in b.c using extern keyword. If yes what is the syntax.

What is the difference in between these two. (If possible.).

Advantage of one over the other?

Poolan
  #2  
Old 03-Dec-2004, 00:38
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
Simple answer... no.

Definition: The keyword extern is used in a declaration to assert to the compiler that the definition for an object or function is in another compilation unit (or file).
__________________
-Aaron
  #3  
Old 03-Dec-2004, 20:18
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,234
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by aaroncohn
Simple answer... no.

Definition: The keyword extern is used in a declaration to assert to the compiler that the definition for an object or function is in another compilation unit (or file).
In other words, extern is used to tell the compiler that the variable mentioned is not actually defined here but in another C file.

File 1 may contain a global variable such as
CPP / C++ / C Code:
int varValues[10];

File 2 needs access to varValues so you specify
CPP / C++ / C Code:
extern int varValues[];

The variable is now available in file 2.
__________________

Cow: You're a lawyer too?
Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase!
  #4  
Old 04-Dec-2004, 22:26
Poolan Poolan is offline
New Member
 
Join Date: Oct 2004
Posts: 19
Poolan is on a distinguished road
Then what does extern {"#include a.c"} means
  #5  
Old 05-Dec-2004, 01:25
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,234
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by Poolan
Then what does extern {"#include a.c"} means
My guess is it means you have a compiler error in your program. I've never seen any syntax like it. If this works for you, please post the code. I'd like to see a working example.
__________________

Cow: You're a lawyer too?
Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase!
  #6  
Old 05-Dec-2004, 23:27
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
I have never seen that syntax. In fact, I think that's impossible. The syntax for extern works in the form:

extern <identifier>
__________________
-Aaron
  #7  
Old 06-Dec-2004, 09:05
BobbyMurcerFan BobbyMurcerFan is offline
Member
 
Join Date: May 2004
Posts: 103
BobbyMurcerFan is on a distinguished road
Quote:
Originally Posted by Poolan
Then what does extern {"#include a.c"} means
According to the MS VC++ 6.0 complier: "warning C4091: 'extern ' : ignored on left of 'int' when no variable is declared"
 
 

Recent GIDBlogFlickr uploads of IA pictures by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 15:41
[GIM][MODULE]Contact List cable_guy_67 FLTK Forum 9 04-Dec-2004 12:19
fltk-2.0 cvs Plumb FLTK Forum 20 13-Nov-2004 07:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:58.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.