The specified identifier was not declared.
A variable’s type must be specified in a declaration before it can be used. The parameters that a function uses must be specified in a declaration, or prototype, before the function can be used.
- Make sure any include file containing the required declaration is not omitted.
- Make sure you are including any necessary header files if you have defined VC_EXTRALEAN, WIN32_LEAN_AND_MEAN, or WIN32_EXTRA_LEAN. Defining these symbols excludes some functionality (certain header files are excluded) from windows.h and afxv_w32.h (for MFC applications) to speed compiles. Search windows.h and afxv_w32.h for these symbols for the most up-to-date description of what is excluded.
- Make sure the identifier name is spelled correctly.
- Make sure the identifier is using the correct upper- and lowercase letters.
- Make sure all string constants have closing quotes.
- This error can be caused by having a newline character in a string constant without a continuation character. For example:
#include <stdio.h>
main() {
printf("\n %s
%s // error: 's' : undeclared identifier
%s",
"this", "is", "it");
}
- Special considerations must be taken when splitting a constant string over several lines. The most common method is to change the format string. Strings separated only by whitespace (spaces, tabs, newlines) are concatenated. For example:
#include <stdio.h>
main() {
printf("\n %s"
" %s"
" %s",
"this", "is", "it");
}
- An older, less-preferred method is to use line continuation by typing a backslash at the end of a line. For example:
printf("\n %s\
%s\
%s",
"this", "is", "it");
This method is not often used because the spaces at the beginning of each continued line become part of the string.
- Make sure you're using proper namespace scope. For example, in order to properly resolve ANSI C++ Standard Library functions and operators, you must state that you're using the std namespace with the using directive.
For example, unless the using directive is uncommented, the following sample will fail to compile because the cout stream is defined in the std namespace:
#include <iostream>
// using namespace std;
void main()
{
cout << "Hello" << endl;
}