CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

problem compiling with header files

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 13, 2015, 22:17
Default problem compiling with header files
  #1
New Member
 
Justin Reiter
Join Date: Feb 2015
Posts: 9
Rep Power: 11
jreiter164 is on a distinguished road
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.
jreiter164 is offline   Reply With Quote

Old   August 14, 2015, 03:29
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
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?
pakk is offline   Reply With Quote

Old   August 14, 2015, 17:31
Default
  #3
New Member
 
Justin Reiter
Join Date: Feb 2015
Posts: 9
Rep Power: 11
jreiter164 is on a distinguished road
Well, I feel silly. I forgot to close my cell loop in the code section above. Thanks for the tip.
jreiter164 is offline   Reply With Quote

Reply

Tags
compile, define_source, header, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 11:32
Search for header files Mar777 Fluent UDF and Scheme Programming 2 April 2, 2013 17:55
UDF compiling problem vagaikwa Fluent UDF and Scheme Programming 6 March 15, 2013 08:33
problem in importing fluent case nad data files to tecplot ganeshranakoti Tecplot 1 March 5, 2013 16:59
UDF compiling problem Wouter Fluent UDF and Scheme Programming 6 June 6, 2012 04:43


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