Why does the Ansys Fluent UDF compiler reports undeclared identifier for a defined variable?
You get the compiler warning 'C2065' 'undeclared identifier' if you use a variable before declaring it and if you declare variables at different locations within your code.
Ansys Fluent expects the code to be written are written in the C (version C99 or earlier) or C++ programming language, which is also called ANSI C. According to this standard, all variables must be declared at the beginning of a function. They may not be declared later within a block.
These rules were removed in later versions of C.
Although Ansys Fluent adds the ansi flag to the makefile, it depends on the compiler if this flag is evaluated correctly.