Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Compilation Errors

warning: unused variable `fp'
Even though I am using the fp variable
 fp=fopen("Reader.xml", "rb");
fgets(Buff, sizeof(Buff), fp);
Anyone know why...
0
sudarshantk
Asked:
sudarshantk
1 Solution
 
grg99Commented:
Try turning off optimization, soemtimes the compiler is too clever.

Also make sure that code is reachable, and not accidentally in a comment or #ifdef or a if( 0 )

0
 
PaulCaswellCommented:
Hi sudarshantk,

FILE * fp; // Will cause a warning.

...

{
  FILE *fp;
  ...
  fp=fopen("Reader.xml", "rb");
  fgets(Buff, sizeof(Buff), fp);
 
}

Perhaps you could post a little more code.

Paul
0
 
marchentCommented:
i din't see any complie error on my VC. by the way try with adding this line on your code for initialization.

FILE *fp=NULL;

regards
marchent
0
 
DineshJolaniaCommented:
Simply , the code is unreachable. That might happen in several ways.
1) You may be returning well before fopen.
2) You might not be calling the function which was not called at all.
3) As above said by grg99
0
 
sudarshantkAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Increase Security & Decrease Risk with NSPM Tools

Analyst firm, Enterprise Management Associates (EMA) reveals significant benefits to enterprises when using Network Security Policy Management (NSPM) solutions, while organizations without, experienced issues including non standard security policies and failed cloud migrations

Tackle projects and never again get stuck behind a technical roadblock.
Join Now