473,385 Members | 1,588 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,385 software developers and data experts.

Error C2065 undeclared identifier

3
I this error while trying to use the identifier that is declared into another header. I have included this header in the cpp and still complains.
Oct 15 '07 #1
4 4576
JosAH
11,448 Expert 8TB
I this error while trying to use the identifier that is declared into another header. I have included this header in the cpp and still complains.
So you did something like:

header file:
Expand|Select|Wrap|Line Numbers
  1. #ifndef MYHEADER_H
  2. #define MYHEADER_H
  3. extern int foo;
  4. #endif
  5.  
source file(s):
Expand|Select|Wrap|Line Numbers
  1. #include "myheader.h"
  2. ...
  3. foo= 42;
  4.  
Did you actually *define* your variable "foo" in exactly one .cpp file? If not the
linker will keep complaining.

kind regards,

Jos
Oct 15 '07 #2
pasta
3
So you did something like:

header file:
Expand|Select|Wrap|Line Numbers
  1. #ifndef MYHEADER_H
  2. #define MYHEADER_H
  3. extern int foo;
  4. #endif
  5.  
source file(s):
Expand|Select|Wrap|Line Numbers
  1. #include "myheader.h"
  2. ...
  3. foo= 42;
  4.  
Did you actually *define* your variable "foo" in exactly one .cpp file? If not the
linker will keep complaining.

kind regards,

Jos
more like
Expand|Select|Wrap|Line Numbers
  1. for (int y = 0; y < foo; y++)
Oct 15 '07 #3
pasta
3
more like

for (int y = 0; y < foo; y++)
where foo is the number of lines I'm reading into memory.
Oct 15 '07 #4
JosAH
11,448 Expert 8TB
where foo is the number of lines I'm reading into memory.
That all is fine but where (in which .cpp file) did you *define* that foo variable?
Header files tell the compiler that somewher such a foo variable is defined and
the compiler believes you but you do have to define it once somewhere in a .cpp
file.

kind regards,

Jos
Oct 15 '07 #5

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

Similar topics

0
by: Stephanie Doherty | last post by:
Hello World, I am trying to use a _spawnl function like this (and I have included the process.h file): _spawnl(_P_WAIT,iporgfile,iporgfile,NULL); It compiles with the following errors: ...
2
by: teddybyte | last post by:
my script below is: #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, ...
2
by: Nick | last post by:
I'm learning C++ and ran into a compile error using Visual C++ 2005 Express on the following example program (located at http://www.cplusplus.com/doc/tutorial/templates.html): // template...
10
by: teddarr | last post by:
I am trying to construct a class with several functions and identifiers. The identifier in question is static double AIR which will hold the value of the annual interest rate in the class. I have...
25
by: notahipee | last post by:
I have been trying to cin an number from 0 to 9 with a leading 0. For example 00 or 07. I was using a switch case. switch (int) { case 01: break; case 02: break;..... My problem arises at 08...
2
by: Gabriel | last post by:
Hi, I downloaded the last platform sdk which works with vc++ 6 (February 2003): http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm However im getting a strange error when...
6
by: muby | last post by:
Hi everybody :) I'm modifying a C++ code in VC++ 2005 my code snippet void BandwidthAllocationScheduler::insert( Message* msg, BOOL* QueueIsFull,
4
by: VikrantS | last post by:
Hi, I am migrating code from VS 6.0 to VS2008. The Code compiles in VS 6.0 but gives the following errors when compiled in VS 2008, --- \Program Files\VC\atlmfc\include\afxcmn.inl(376) : error...
4
by: backen | last post by:
Hi! i cant get this code to work, I get error c2065, undeclared identifier for some reason donīt really know why... this results in error C2146: syntax error : missing ';' before identifier...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.