LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compile errors when calling dll

Hi,

I am following example 1 in the labview documentation on calling external code from a dll. I am using labview 7.1 with the microsoft visual C++ compiler.

I want to compile this source code

/* Call Library source file */

_declspec(dllexport) long avg_num(float a[], long size, float *avg);

_declspec(dllexport) long avg_num(float a[], long size, float *avg)
    {

    int i;
    float sum = 0;
    if (a != NULL)
        {
        for(i = 0; i < size; i++)
            sum = sum + a[i];
        }
    else
        return (i);
    *avg = sum / size
    return (0);
    }

into a dll file but get the following errors.

Does anyone have any suggestions.

Deleting intermediate files and output files for project 'myshared - Win32 Debug'.
--------------------Configuration: myshared - Win32 Debug--------------------
Compiling...
myshared.c
c:\documents and settings\user\desktop\array average\myshared.c(10) : error C2065: 'NULL' : undeclared identifier
c:\documents and settings\user\desktop\array average\myshared.c(10) : warning C4047: '!=' : 'float *' differs in levels of indirection from 'int '
c:\documents and settings\user\desktop\array average\myshared.c(18) : error C2143: syntax error : missing ';' before 'return'
Error executing cl.exe.

myshared.dll - 2 error(s), 1 warning(s)



Thank you,

-Tim
0 Kudos
Message 1 of 2
(2,717 Views)

Obviously grammer mistake:

*avg = sum / size miss a ";"

if you don't include the stdio.h, you'd better add #define NULL  (* void)0

Message 2 of 2
(2,705 Views)