CFD Online Logo CFD Online URL
Home > Forums > Fluent UDF and Scheme Programming

can not include Windows.h and sys/stat.h headers

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   July 19, 2013, 09:39
Default can not include Windows.h and sys/stat.h headers
New Member
Join Date: Apr 2013
Posts: 20
Rep Power: 6
eromon84 is on a distinguished road
Hi all,

I have made a UDF and I am having numerous errors when I try and use the following headers

#include <Windows.h>
#include <sys/stat.h>

for the windows header fluent gives me huge amount of redifinition errors or
says unexpected '$' in macro definition etc.

for the <sys/stat.h> header I keep getting linker errors for undefined struct stat.

following code is where I use stat to check of a file exists.

int FileExists(const char* filename){
struct __stat64 buf;
stat(filename, &buf);

/* stat(filename, &buf) returns 0 for completion and -1 for fail */
if ( stat(filename, &buf) == -1)

/* returns false if file does not exist */
return 0;

/* returns true if a file already exists */

return 1;

i have tried using struct_stat64 and struct stat but this is still not working.

this piece of code compiles fine on Xcode ( just for testing) and VS2010.

I am using VS2010 Express and installed SDK 7.1. Installed SDK 7.1 first due to failed installation occuring if I tired to install it after VS2010 Express.

also needed the Windows.h file for the Sleep( time in milliseconds ) command . If I file does not exists I needed it to pause for very short time before checking again, did not want the program speeding away and crashing.

EDIT: actual error for the stat problem

Additional_functions.obj : error LNK2019: unresolved external symbol stat referenced in function FileExists
libudf.dll : fatal error LNK1120: 1 unresolved externals
eromon84 is offline   Reply With Quote

Old   October 24, 2014, 23:07
New Member
Join Date: Jul 2014
Posts: 4
Rep Power: 5
wenjue is on a distinguished road
Did you solve this problem at last? I have the same problem as you did. Could you please help me out?
wenjue is offline   Reply With Quote

Old   February 6, 2017, 12:49
New Member
Join Date: Sep 2015
Posts: 8
Rep Power: 4
Alex41 is on a distinguished road

Have you figured out how to include <Windows.h> in your code?

Anyone has an idea how to include <Windows.h> in FLUENT UDF?

Kind regards,

Alex41 is offline   Reply With Quote

Old   February 7, 2017, 06:38
Senior Member
Join Date: Nov 2013
Posts: 1,104
Rep Power: 15
pakk will become famous soon enough
The compiler does not know where to find windows.h. So maybe you can replace
#include <Windows.h>
#include "c:\correct_folder\Windows.h"
Having said that, I think that for Fluent UDFs it is better to avoid windows.h. Probably it is only necessary for very specialized complex applications. If you don't know how to include windows.h, you will probably not good enough in programming to make those specialized complex applications. With "complex" I don't mean mathematically or physically complex, but that you need to interact with background processes in windows or whatever.

(I am not trying to insult anybody for being a bad programmer: I think I am myself also not good enough to make specialized complex applications that really need windows.h.)
pakk is offline   Reply With Quote


Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

All times are GMT -4. The time now is 03:56.