CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   Errors when Compiling UDF: error C2040/error C2099 (

Julian K. December 19, 2008 05:30

Errors when Compiling UDF: error C2040/error C2099

I would like to use a very simple UDF, which writes informations of particles into a file. For compiling the UDF, I downloaded 'Visual C++ 2008 Express', go to the 'libudf\ntx86\3d>' directory and type 'nmake'.

Here is my UDF-Code:


/*#define USE_FLUENT_IO_API 1*/


#include "udf.h"

FILE *fp;

fp = fopen ("myfile.txt","w");

DEFINE_DPM_OUTPUT(discrete_phase_sample,header,fp, p,t,plane)


float x,y,z;

x = P_POS(p)[0];

y = P_POS(p)[1];

z = P_POS(p)[2];

fprintf(fp,"%d %f %f %f\n",p->part_id, x, y, z);



Quite simple I guess, but anyhow, my computer doesn't like the 'FILE' command. Here is what I get, after I typed 'nmake':


Setting environment for using Microsoft Visual Studio 2008 x86 tools.


Microsoft (R) Program Maintenance Utility Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved.

cl /c /Za /DUDF_EXPORTING -Ic:\\fluent6.3.26\ntx86\3d -Ic:\fl\fluent6.3.26\src -Ic:\\fluent6.3.26\cortex\src -Ic:\fluent. inc\fluent6.3.26\client\src -Ic:\\fluent6.3.26\tgrid\src -Ic:\fluent .inc\fluent6.3.26\multiport\src ..\..\src\dpm_counter.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved.


..\..\src\dpm_counter.c(14) : error C2040: 'pFile' : 'int' differs in levels of indirection from 'FILE *'

..\..\src\dpm_counter.c(14) : error C2099: initializer is not a constant NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN \cl.EXE"' : return code '0x2' Stop.



Here are some information about my system:

Windows Vista 32-bit

dual-core 1.6GH 64-bit

Fluent 6.3

Visual C++ 2008 Express Edition

I searched the Forum and the internet for some solution but couldn't find any.

Hope, you can help me,

best wishes,


sk December 21, 2008 01:23

Re: Errors when Compiling UDF: error C2040/error C

try to start fluent from Vc++ command prompt and then compile udf.. Hopefully it will work. almost all the 'nmake' error occurs because of this.

regards sk.

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