473,387 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

using an array of structures in multiple .cpp files in VC++

hi,
my project has a header file structure.h which has the following code

Expand|Select|Wrap|Line Numbers
  1. #ifndef STRUCTURE_H
  2. #define STRUCTURE_H
  3. #include <stdio.h>
  4.  
  5. typedef struct 
  6. {
  7.     float x,y,z;
  8.  
  9. }position_s ;
  10.  
  11. typedef struct 
  12. {
  13.     float r,g,b,a;
  14.  
  15. }color_s ;
  16.  
  17. typedef struct 
  18. {
  19.     int size; 
  20.     bool blend;
  21.     position_s pos;
  22.     color_s colour;
  23.  
  24. }point_s;
  25.  
  26. extern point_s dp[];
  27. #endif
  28.  
I need to create a dynamic array of point_s structure objects ( the array may be as large as a million depending on the number of points present in a file).

one .cpp file is used for reading a file( of specific format which gives x y z r g b values) and these values shud be stored in the structure objects ( objects in the array dp).

this array shud be accessible to another .cpp file which displays the points on a 3D window.

I have included structure.h in both the files but it gives a build error

filehandling.obj : error LNK2019: unresolved external symbol "struct point_s * dp" (?dp@@3PAUpoint_s@@A) referenced in function "void __cdecl fileopen2(void)" (?fileopen2@@YAXXZ)
fatal error LNK1120: 1 unresolved externals

Can anyone help me with this?

thank you.
Feb 28 '08 #1
1 2064
Banfa
9,065 Expert Mod 8TB
The line

extern point_s dp[];

just declares a variable of type point_s * it does not define it. A declaration says something exists, where as a definition creates it. You have said dp exists but because you have not defined it it does not exist so you get unresolved external (it doesn't exist) errors.

You need to put

point_s *dp;

in a cpp file somewhere.
Feb 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Linux Inquirer | last post by:
Hi Guys, I need to pass a C structure of this form from VB6 <-> VC++ 6 struct BTag { int rowIndex; BSTR* valueList; } B;
8
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out |...
8
by: michi | last post by:
Hello everybody, I have following problem: I have an array of pointers to structures: table* tab = new table; and structure table is like this: struct table{ CSLL::node* chain;
2
by: AMT2K5 | last post by:
Hello. When I compile my program I recieve lots and lots of the following message which I am trying to decipher. "xxx was declared deprecated". What exactly does that mean?
4
by: Danny Mavromatis | last post by:
I'm trying to set up a structure using unions (fieldoffset) and I'm running into a problem. When I try to setup a union of data array or message type, I get the following error: ...
2
by: efrat | last post by:
Hello, I'm planning to use Python in order to teach a DSA (data structures and algorithms) course in an academic institute. If you could help out with the following questions, I'd sure...
1
by: CapMaster | last post by:
I've found some programs of how to create a standard game of blackjack on C++. But how would you do it using structs? Here is my assignment: Problem Statement: The purpose of this project is to...
7
by: Pete | last post by:
I need to import multiple tab delimited files for which I do not have the formats. All files have column headers in the the line. The files must be dynamic. The only common value is that the...
2
by: Phoenix | last post by:
Hi Friends , Could anyone please help me to resolve the following issue : I pass an array of structures to a dll written in VC++ 6.0 whih fills it with data . The following works well for VB...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.