|
[Sponsors] |
August 13, 2015, 23:17 |
problem compiling with header files
|
#1 |
New Member
Justin Reiter
Join Date: Feb 2015
Posts: 9
Rep Power: 11 |
I have taken some C code from the book Numerical Recipes in C and modified them for creating a UDF. The code uses two header files which define several function prototypes for the main code. I have these header files included at the top of my UDF along with udf.h.
I get a series of strange error messages regarding a define_source macro. Here is a representative section of code, with the corresponding error messages. The first error message corresponds to the first line (143), "DEFINE_SOURCE(ca_source..." DEFINE_SOURCE(ca_source,c,t,dS,eqn) { float ca_source; ca_source=density*C_UDMI(c,t,0); return ca_source; } ..\..\src\test.c(143) : error C2275: 'real' : illegal use of this type as an expression c:\program files\ansys inc\v140\fluent\fluent14.0.0\src\global.h(167) : see declaration of 'real' ..\..\src\test.c(143) : error C2146: syntax error : missing ';' before identifier 'ca_source' ..\..\src\test.c(143) : error C2143: syntax error : missing ')' before 'type' ..\..\src\test.c(143) : error C2059: syntax error : ')' ..\..\src\test.c(146) : error C2440: '=' : cannot convert from 'double' to 'int (*)()' ..\..\src\test.c(147) : warning C4098: 'equilibrium_speciation' : 'void' function returning a value It seems that the compiler does not agree with something in my header files or the way I am declaring my variables. The error messages refer to real and double types even though my code only uses floats. 1) I was under the impression float type could be used instead of real for UDFs. Is this not true? 2) The last error message points to line 147, which is the last line of my DEFINE_SOURCE macro. The "equilibrium_speciation" title it references earlier in the error message is from a DEFINE_ADJUST macro I have before that define_source. In other words, line 147 is not within the "equilibrium speciation" section of code, so I'm not sure what to make of that error. 3) Am I missing some fundamental piece of information regarding using custom header files for compilation? If anyone has experience using custom header files or can shed any light on these issues it would be greatly appreciated. |
|
August 14, 2015, 04:29 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I have the feeling that your problem might be directly above line 143. Maybe you did not add a semicolon in the previous code line? Can you show what is directly before this code?
|
|
August 14, 2015, 18:31 |
|
#3 |
New Member
Justin Reiter
Join Date: Feb 2015
Posts: 9
Rep Power: 11 |
Well, I feel silly. I forgot to close my cell loop in the code section above. Thanks for the tip.
|
|
Tags |
compile, define_source, header, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem compiling a custom Lagrangian library | brbbhatti | OpenFOAM Programming & Development | 2 | July 7, 2014 12:32 |
Search for header files | Mar777 | Fluent UDF and Scheme Programming | 2 | April 2, 2013 18:55 |
UDF compiling problem | vagaikwa | Fluent UDF and Scheme Programming | 6 | March 15, 2013 09:33 |
problem in importing fluent case nad data files to tecplot | ganeshranakoti | Tecplot | 1 | March 5, 2013 17:59 |
UDF compiling problem | Wouter | Fluent UDF and Scheme Programming | 6 | June 6, 2012 05:43 |