Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve identifier on netbeans

I'm keep getting this "Unable to resolve identifier file" message on netbeans. I'm new in c and netbeans. It was fine last night but somehow after rebooting my computer this message keep occurs. Here's a code. What would be the problem?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char** argv) {
  char filename[] = "text.dat";
  char line[5];
  FILE *file = fopen(filename, "r");
  return 0;
}
like image 547
Max Avatar asked Jun 01 '11 09:06

Max


1 Answers

I know this is an old post, but I ran into the same issue today. Don't be too quick to assume a compiler-supplied header file is defective. That is rarely the case, especially for headers such as stdio.h that have been around a long time.

Keep in mind that Netbeans code assistance references the includes used within your source code. Any macros that are used by the compiler must be defined to Netbeans. A file such as stdio.h may have conditional includes based on one or more macros. Unless Netbeans is aware of those macros it cannot apply them when it processes include files to provide code assistance. This would prevent conditional headers containing symbols from being loaded.

For example, today I saw that an include file I use has many conditional includes and the symbols Netbeans reported it could not resolve were defined in those files. Knowing that I was building for a particular processor I determined the macro needed for the proper file to be included within . I then defined that macro in Project Properties/Code Assistance/C Compiler/Preprocessor Definitions. At that point Netbeans was able to resolve the symbols.

like image 163
Lawrence J. Sylvain Avatar answered Sep 25 '22 12:09

Lawrence J. Sylvain