home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Passing structures between files

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1610
Discussions: 200,925, Posts: 2,379,127, Members: 246,291
Old June 25th, 2003, 12:16 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Jun 2003
Posts: 2
Passing structures between files

I am trying to pass a structure between two files that are compiled independently as part of the same project.


I have two files (file1, file2) as well as an include file. Both file1 and file 2 include the include file.

include.h is the include file, and contains the following:

struct randy_struc {
char *name; //name of option i.e frequency
int value [6]; //value of option
int max_choices; //total number of values for options (20 max)
char *value_string [20]; //string that displays
} ;



In file 1, I have a definition of a member of the structure:

randy_struc
randy_option_1 = //don't change
{" Host interface ",
{3,3,3,3,3,3},
3,
{
"",
"ISA ",
"SMB ",
"None",
},
};
For now assume the structure isnt referenced by file 2, I can then compile my program error free and it works. But now I want access to the structure from file 2 so I add the following to file 2:

extern struct randy_struc; (or several derivatives of the same thing)


I end up with a compiler error message (BC4.2) of "storgae class extern is not allowed here"

Any ideas ?
briang5 is offline   Reply With Quote
Old July 5th, 2003, 08:38 PM     #2 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
Join Date: Oct 2001
Posts: 1,542
Re: Passing structures between files

Quote:
Originally posted by briang5
But now I want access to the structure from file 2 so I add the following to file 2:

extern struct randy_struc; (or several derivatives of the same thing)


I end up with a compiler error message (BC4.2) of "storgae class extern is not allowed here"

struct randy_struc is the name of a structure type, which you already have included. Perhaps you want to reference a variable, an instance of the structure type?
strangerstill is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2865)
Obama the Muslim (14)
Is the PSU I received dead? (10)
windows vista security holes (9)
Foreign voltage (10)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (10)
Print spooler problem (13)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
Ideal cheap graph card for PC-Gamin.. (15)
New Computer wont recognize XP disc (7)
EVGA 9800 gtx help with finding a g.. (8)
World's largest Monopoly Game using.. (331)
Recent Discussions
radeon x850xt platinum & shader 3 (3)
Have you switched yet? (84)
Install XP pro and a Vista laptop ?? (10)
Wireless Router+Cable Modems and Much.. (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
Fire in DVD (0)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)
Print spooler problem (13)
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
monitor will not turn on at all, (1)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
EVGA 9800 gtx help with finding a goo.. (8)
Modern Warfare For the PC (32)
Problem with speed step/turbo boost? (1)
Modern Warfare 2: Who Bought It? (61)
SIS 740 and Widescreen (8)


All times are GMT -4. The time now is 12:49 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28