CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Errors when Compiling UDF: error C2040/error C2099 (https://www.cfd-online.com/Forums/fluent/50090-errors-when-compiling-udf-error-c2040-error-c2099.html)

Julian K. December 19, 2008 04:30

Errors when Compiling UDF: error C2040/error C2099
 
Hallo,

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*/

#define USE_FLUENT_IO_API 0

#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.

c:\Users\Casper\Desktop\UDF-test\libudf\ntx86\3d>nmake

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

cl /c /Za /DUDF_EXPORTING -Ic:\fluent.inc\fluent6.3.26\ntx86\3d -Ic:\fl uent.inc\fluent6.3.26\src -Ic:\fluent.inc\fluent6.3.26\cortex\src -Ic:\fluent. inc\fluent6.3.26\client\src -Ic:\fluent.inc\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.

dpm_counter.c

..\..\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.

c:\Users\Casper\Desktop\UDF-test\libudf\ntx86\3d>

------------------------------------------------------------

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,

Julian


sk December 21, 2008 00:23

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

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 03:53.