Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
This time Iam Struggling with C++,as Iam very new to this I have some start up difficulties also.In this project Iam using so many Header files and libraries.While building the application it is showing: fatal error C1083: Cannot open include file,but the file is already included.While searching with this error I came to know that if the path given is incorrect then also this error will come.So I checked that also.Everything Ok but again it is showing fatal error C1083: Cannot open include file.

Please suggest some help.

Below is my code:

C++
#include "StdAfx.h"
#include 
#include "TciCons.h"
#include "tftai.h"
#define TFTime __time32_t
#include "tfdescr.h"
#include "exinfo.h"
#include "tai.h"
#include 
#include 
#include 
#include 

#include "..\include\drvstandard.h"
#include "..\include\drvtool.h"			// prototypes driver development
#include "..\include\UniTCPIPImports.h" // prototypes and defines to TCP/IP communication library
#include "..\include\unicode.h"
#include "TsTCPAlarmItem.h"

#define DRIVER_NAME		_T("TSTCP")
static TCHAR szDrvVersion[] = _T("1.1.01");

unsigned long localtime_julian(long tim);

int ServiceRequest( COM_RESP_REC& com_resp_rec );

#define BUFSIZE1 512*1024 


CTciCons::CTciCons(void)
{
	nProtocol = PROTOCOL_DB2;
	pArchive = NULL;
	pSetup = NULL;  
	pSetupExtra = NULL;
	memset( &CpcRespRec, 0, sizeof(CpcRespRec));
	memset( &Db2Params, 0, sizeof(Db2Params));
	memset( &Db2, 0, sizeof(Db2));
	memset( &Db1, 0, sizeof(Db1));
	dnl_buf = new unsigned char[BUFSIZE1];

	strncpy( CpcRespRec.com_req.idnum, "EM002", 10);

	memcpy( CpcRespRec.com_req.scode,"0000",4 );
	strncpy(CpcRespRec.com_req.phone_nbr, "T166.131.58.7/12345", 25);
	CpcRespRec.com_req.comport = 11;							
	//CpcRespRec.com_req.baud = 9600;	
	CpcRespRec.com_req.linktime = 0;							
	CpcRespRec.com_req.retries = 3;
	strcpy( CpcRespRec.com_req.work_station_id,"EM002");
	CpcRespRec.com_req.rem_dev_type = 0;	// FCU
	CpcRespRec.com_req.time_out = 10;
	CpcRespRec.com_req.com_type = 10;		// tcp/ip
	
	Db2.bCompressed = 0;
	Db2.MaxDataBlockSize = 1024;
	Db2.MaxPacketSize = 8 * 1024;	
	Db2.RemoteRespTimeoutSecs = 10;
	Db2.retries = 3;
	Db2.RemoteACKTimeoutSecs = 10;
	Db2.CharacterTimeoutSecs = 2;

	/*Db1.retries = 3;
	Db1Params.nCollectDays = 0;
	Db1Params.nDataResolution = 0;
	Db1Params.nReqType = 0;*/

	memset(&GlobalpbutRespRec, 0, sizeof(GlobalpbutRespRec));
	memset(&GlobalkdtRespRec, 0, sizeof(GlobalkdtRespRec));
	memset(&GlobalValve, 0, sizeof(GlobalValve));
}

CTciCons::~CTciCons(void)
{
	delete dnl_buf;
	if(pArchive)
		ReleaseArchive(pArchive);
	if(pSetup)
		delete pSetup;
	if(pSetupExtra)
		delete [] pSetupExtra;
}

////////////// Driver Configuration standard functions  /////////////////
//
// The functions not declared are replace by default functions

int CTciCons::ProcessCommand(int cmd)
{
char bfr[80];
ULONG now;
int opt=cmd;
if(opt<0)
{
	if(nProtocol==PROTOCOL_DB1)
		opt=GetDB1Option();
	else
		opt=GetDB2Option();
}
if(opt==0||opt==100) return 0;
if(opt==1||opt==101)
{
	if(nProtocol==PROTOCOL_DB1)
	{
		nProtocol=PROTOCOL_DB2;
		CpcRespRec.com_req.linktime=0;
		CpcRespRec.com_req.com_type=10;
	}
	else
	{
		nProtocol=PROTOCOL_DB1;
		CpcRespRec.com_req.linktime=1;
		CpcRespRec.com_req.com_type=0;
	}
	return -1;
}
CpcRespRec.com_req.dnl_buf=(char*)dnl_buf;
switch(opt)
{
case 2:
	BuildRegisterRequest(&CpcRespRec.com_req,&Db2,9,0,0,1);
    ServiceRequest(CpcRespRec);
	ShowRegisters();
	break;
case 3:
	float tmp[3];
	tmp[0]=(float)1003;
	tmp[1]=(float)0.7;
	tmp[2]=(float)0;
	BuildRegisterDownload(&CpcRespRec.com_req,&Db2,9,0,1,1,(char *)tmp,4);
	AddRegisterDownload(&CpcRespRec.com_req,9,0,4,1,(char *)(tmp+1),4);
	ServiceRequest(CpcRespRec);
	ShowStatus();
	break;
}
delete CpcRespRec.rsp_buf;
memset(bfr,0,sizeof(bfr));
gets(bfr);
if(strlen(bfr)==0) return -1;
return atoi(bfr);
}
int CTciCons::GetDB1Option()
{
	
}
int CTciCons::GetDB2Option()
{
	int rtn = 0;
	char buffer[25];
	printf( "_____________________________ \n");
//	printf( "DB2 Protocol - Choose an Option!\n");
	printf( "Ready To Poll!\n");
	printf( "0) To quit\n");
	//printf( "1) Switch to DB1\n");
	printf( "3) Read Register\n");
	printf( "4) Write Register\n");
	memset(buffer, 0, sizeof(buffer));
	gets(buffer);
	if(strlen(buffer) == 0) return 0;
	return atoi(buffer);
}

And the showing missing file is "exinfo.h"
Posted
v2
Comments
Matthew Faithfull 14-Mar-13 4:17am    
You need to give a little more information such as which file is failing to be included and where is the #include statement itself? What inclusion paths are set in your development environment? Then it may be possible to help.
danil33 14-Mar-13 4:21am    
Below is my code:

#include "StdAfx.h"
#include <iostream>
#include "TciCons.h"
#include "tftai.h"
#define TFTime __time32_t
#include "tfdescr.h"
#include "exinfo.h"
#include "tai.h"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include "..\include\drvstandard.h"
#include "..\include\drvtool.h" // prototypes driver development
#include "..\include\UniTCPIPImports.h" // prototypes and defines to TCP/IP communication library
#include "..\include\unicode.h"
#include "TsTCPAlarmItem.h"

#define DRIVER_NAME _T("TSTCP")
static TCHAR szDrvVersion[] = _T("1.1.01");

unsigned long localtime_julian(long tim);

int ServiceRequest( COM_RESP_REC& com_resp_rec );

#define BUFSIZE1 512*1024


CTciCons::CTciCons(void)
{
nProtocol = PROTOCOL_DB2;
pArchive = NULL;
pSetup = NULL;
pSetupExtra = NULL;
memset( &CpcRespRec, 0, sizeof(CpcRespRec));
memset( &Db2Params, 0, sizeof(Db2Params));
memset( &Db2, 0, sizeof(Db2));
memset( &Db1, 0, sizeof(Db1));
dnl_buf = new unsigned char[BUFSIZE1];

strncpy( CpcRespRec.com_req.idnum, "EM002", 10);

memcpy( CpcRespRec.com_req.scode,"0000",4 );
strncpy(CpcRespRec.com_req.phone_nbr, "T166.131.58.7/12345", 25);
CpcRespRec.com_req.comport = 11;
//CpcRespRec.com_req.baud = 9600;
CpcRespRec.com_req.linktime = 0;
CpcRespRec.com_req.retries = 3;
strcpy( CpcRespRec.com_req.work_station_id,"EM002");
CpcRespRec.com_req.rem_dev_type = 0; // FCU
CpcRespRec.com_req.time_out = 10;
CpcRespRec.com_req.com_type = 10; // tcp/ip

Db2.bCompressed = 0;
Db2.MaxDataBlockSize = 1024;
Db2.MaxPacketSize = 8 * 1024;
Db2.RemoteRespTimeoutSecs = 10;
Db2.retries = 3;
Db2.RemoteACKTimeoutSecs = 10;
Db2.CharacterTimeoutSecs = 2;

/*Db1.retries = 3;
Db1Params.nCollectDays = 0;
Db1Params.nDataResolution = 0;
Db1Params.nReqType = 0;*/

memset(&GlobalpbutRespRec, 0, sizeof(GlobalpbutRespRec));
memset(&GlobalkdtRespRec, 0, sizeof(GlobalkdtRespRec));
memset(&GlobalValve, 0, sizeof(GlobalValve));
}

CTciCons::~CTciCons(void)
{
delete dnl_buf;
if(pArchive)
ReleaseArchive(pArchive);
if(pSetup)
delete pSetup;
if(pSetupExtra)
delete [] pSetupExtra;
}

////////////// Driver Configuration standard functions /////////////////
//
// The functions not declared are replace by default functions

int CTciCons::ProcessCommand(int cmd)
{
char bfr[80];
ULONG now;
int opt=cmd;
if(opt<0)
{
if(nProtocol==PROTOCOL_DB1)
opt=GetDB1Option();
else
opt=GetDB2Option();
}
if(opt==0||opt==100) return 0;
if(opt==1||opt==101)
{
if(nProtocol==PROTOCOL_DB1)
{
nProtocol=PROTOCOL_DB2;
CpcRespRec.com_req.linktime=0;
CpcRespRec.com_req.com_type=10;
}
else
{
nProtocol=PROTOCOL_DB1;
CpcRespRec.com_req.linktime=1;
CpcRespRec.com_req.com_type=0;
}
return -1;
}
CpcRespRec.com_req.dnl_buf=(char*)dnl_buf;
switch(opt)
{
case 2:
BuildRegisterRequest(&CpcRespRec.com_req,&Db2,9,0,0,1);
ServiceRequest(CpcRespRec);
ShowRegisters();
break;
case 3:
float tmp[3];
tmp[0]=(float)1003;
tmp[1]=(float)0.7;
tmp[2]=(float)0;
BuildRegisterDownload(&CpcRespRec.com_req,&Db2,9,0,1,1,(char *)tmp,4);
AddRegisterDownload(&CpcRespRec.com_req,9,0,4,1,(char *)(tmp+1),4);
ServiceRequest(CpcRespRec);
ShowStatus();
break;
}
delete CpcRespRec.rsp_buf;
memset(bfr,0,sizeof(bfr));
gets(bfr);
if(strlen(bfr)==0) return -1;
return atoi(bfr);
}
int CTciCons::GetDB1Option()
{

}
int CTciCons::GetDB2Option()
{
int rtn = 0;
char buffer[25];
printf( "_____________________________ \n");
// printf( "DB2 Protocol - Choose an Option!\n");
printf( "Ready To Poll!\n");
printf( "0) To quit\n");
//printf( "1) Switch to DB1\n");
printf( "3) Read Register\n");
printf( "4) Write Register\n");
memset(buffer, 0, sizeof(buffer));
gets(buffer);
if(strlen(buffer) == 0) return 0;
return atoi(buffer);
}

And the showing missing file is "exinfo.h"
Matthew Faithfull 14-Mar-13 4:36am    
OK all we need now is the actual path to "exinfo.h" on the disk and the set of search directories, in order, from your IDE or build environment.
May be the files are present in C Directory, which is not accessible by Application.
So, move those files somewhere in other Directories like D or E and try.
danil33 14-Mar-13 4:29am    
Yes the files were present in the C directory.So I shifted them to D directory again it is showing the same error.

You have to make sure the file is in the compiler search path. For instance with Visual Studio 2005, click on Tools->Options menu item, then select Projects And Solutions->VC++ Directories, choose Include Files in the list just below Show Directories For: label and finally add your include file folder.
 
Share this answer
 
Solution 1 is correct (see that one first). If that doesn't fix your problem however, you might have a infinite loop in your header includes. If you include header1.h, which includes header2.h, which includes header1.h again, the compiler gets upset. You can get indemnity from this with:
- ensuring you don't have include loops manually
- #pragma once
- header guard blocks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900