473,805 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error C2065 undeclared identifier

3 New Member
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 4603
JosAH
11,448 Recognized Expert MVP
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 New Member
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 New Member
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 Recognized Expert MVP
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
1496
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: error C2065: '_P_WAIT' : undeclared identifier
2
3386
by: teddybyte | last post by:
my script below is: #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
2
3934
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 specialization #include <iostream> using namespace std; template <class T> class container {
10
11813
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 been getting an error message that I can't seem to get rid of: error C2065: 'AIR' undeclared identifier I have never worked with static identifiers before and I think I'm leaving something out somewhere but I don't know what. Here's the...
25
4030
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 and 09 because they are not octal. Is there any way to coerce the input variable to decimal despite it having a leading zero .
2
3705
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 i compile. what i do is the following: - Run this shortcut from the start menu to set variables: Set Windows XP 32-bit Build Environment (Retail).lnk
6
38084
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
6026
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 C2065: 'TVM_GETLINECOLOR' : undeclared identifier E:\Program Files\VC\atlmfc\include\afxcmn.inl(378) : error C2065: 'TVM_SETLINECOLOR' : undeclared identifier E:\Program Files\VC\atlmfc\include\afxcmn.inl(394) : error C2065: 'TVIF_STATEEX' :...
4
3613
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 'Sorter' and error C2065: 'Sorter' : undeclared identifier.... furthermore, I am not sure that my sorter will work (later problem =)) And I hope here is a kind soul that can help me out =) the code: #include <iostream> #include <string>
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.