CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   for loop compile error (https://www.cfd-online.com/Forums/fluent-udf/174871-loop-compile-error.html)

AHF July 20, 2016 06:59

for loop compile error
 
Hi
can i use for loops in udf ?
like this :

for (int j = 10 ; j >= 0 ; j = j - 1)
{
.......;
}

errors :
error C2143: syntax error : missing ';' before 'type'
error C2143: syntax error : missing ')' before 'type'
error C2065: 'j' : undeclared identifier
warning C4552: '>=' : operator has no effect; expected operator with side-effect

Bruno Machado July 20, 2016 07:17

Quote:

Originally Posted by AHF (Post 610432)
Hi
can i use for loops in udf ?
like this :

for (int j = 10 ; j >= 0 ; j = j - 1)
{
.......;
}

errors :
error C2143: syntax error : missing ';' before 'type'
error C2143: syntax error : missing ')' before 'type'
error C2065: 'j' : undeclared identifier
warning C4552: '>=' : operator has no effect; expected operator with side-effect

i'd define j as a global variable and create an if like

if (j >= 0)
{
...
j--;
}


All times are GMT -4. The time now is 22:24.