LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CIN with C++

Hi, Sirs,

Anybody ever used CIN(code interface node) with Visual/Borland C++ in
LabVIEW 5.1? As a newguy in LabVIEW, I have been struggling for a week to
build a very simple C code to *.lsb file, a kind of CIN that LabVIEV
recognizes. What C++ responded me was:

error C2146: syntax error : missing ';' before identifier 'MgErr'
error C2501: 'CIN' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found
Error executing cl.exe.

I will appreciate if you'd like to offer your kind advice. Thanks.

GC
0 Kudos
Message 1 of 3
(5,674 Views)
Well, let me deliver more details. It is a very simple CIN. Its source
code is:
/************************************************/
// mult.cpp : Defines the entry point for the DLL application.
//

/*
* CIN source file
*/
#include "extcode.h"
#include "hosttype.h"
#include "StdAfx.h"


CIN MgErr CINRun(float *a, float *b, float *a_b);
CIN MgErr CINRun(float *a, float *b, float *a_b) {

/* ENTER YOUR CODE HERE */

*a_b = *a * *b;
return noErr;
}
/*************************************/

Where "CIN" "MgErr" "CINRun" are supposed to be defined in "extcode.h"
plus "hosttype.h", both provided by LabVIEW. And all of codes except the
line "*a_b=*a * *b;" are automatically generated by LabVIEW. This simple
project also includes resource file
s: cin.obj, lvsb.lib, labview.lib,
lvsbmain.def, all provided by Labview. Now let's see the error
information:

/*******************
error C2146: syntax error : missing ';' before identifier 'MgErr' error
C2501: 'CIN' : missing storage-class or type specifiers fatal error C1004:
unexpected end of file found
****************/

Obviously, the errors are produced in the following line:

CIN MgErr CINRun(float *a, float *b, float *a_b);

My thought is VC++ might not understand "CIN" stuffs for some reasons.
But you know, I just follow the LabVIEW mannual step by step. Is there
any more enviroment variables necessary to be adjusted?

Any more details I shoud post?

I'll appreciate your time and kindness.

GC
0 Kudos
Message 2 of 3
(5,674 Views)
Hello,

I never tried CINs under LV 5.1, 5.0.1f1 ist the latest revison I used.

I repeat here a posting sent to info-labview@pica.army.mil quite a while ago.

It descibes
the steps you have to take when using the Microsoft Developer Studio (MDS)
environment
of Visual C++ (Version 6 AFAIK) for CINs:

*****Begin of repeated posting****
*****************************
- Use the Microsoft Developer studio (MDS)

- In the InfoView section go to: Visual C++ Books->User's
Guides->Visual C++ User's Guide->Working with projects->Using
External Projects->Opening an existing Makefile

- Proceed to the section: "To open an existing makefile without the
extension .MAK"

- Follow the instructions and open the LabVIEW .lvm file for the
project you want to compile (e.g. mult.lvm to compile mult.c in
the /labview/examples/cins/mult directory).

- MDS will create a wrap-around makefile (default name in this example
would be mult1.mak)

- modify the original mult.lvm to read as follows:

IDE = VC
CINTOOLSDIR=C:\LABVIEW\CINTOOLS
name=mult
type=CIN
codeDir = c:\labview\examples\cins\mult
!include <$(CINTOOLSDIR)\ntlvsb.mak>

codeDir must of course point to the dir where your main .c file
resides

also keep in mind to use the DOS compatible versions of long directory
names (or limit your dir's names to 8 chars)

(ntlvsb.mak might be a different name if you don't work in
Win95/WinNT)

- (optional)
in the line after codeDir = ... you can optionally add a line like

objFiles = name1.obj name2.obj ....

to inform MDS about additional .obj files your main file might
depend on

- (optional)
with 'Insert/Files into Project...' (from the main MDS menu) you can
add all files your project might depend on to the file list for
easier access in the MDS environment.

- Choose 'Build' from MDS's Project toolbar (or press F7) to build the
project.

- if it runs successful, you will find mult.lsb in your codeDir and
can load it as a code resource in LabVIEW into the CIN node in the
mult.vi diagram.

***End of posting***
******************

This has been tested with LV 5.0.1, and definitely would compile your simple
example which just multiplies two numbers.
If you do it like described above and it still does not work, it might be
related
to some change in LV 5.1 (which I don't have yet).

Hope this helps



Guoxiang Chen schrieb:

> Hi, Sirs,
>
> Anybody ever used CIN(code interface node) with Visual/Borland C++ in
> LabVIEW 5.1? As a newguy in LabVIEW, I have been struggling for a week to
> build a very simple C code to *.lsb file, a kind of CIN that LabVIEV
> recognizes. What C++ responded me was:
>
> error C2146: syntax error : missing ';' before identifier 'MgErr'
> error C2501: 'CIN' : missing storage-class or type specifiers
> fatal error C1004: unexpected end of file found
> Error executing cl.exe.
>
> I will appreciate if you'd like to offer your kind advice. Thanks.
>
> GC

--
Dr. Franz Josef Ahlers
Physikalisch-Technische Bundesanstalt
Bundesallee 100
D-38116 Braunschweig
tel +49 531 592 2410
fax +49 531 592 2405
email franz.ahlers@ptb.de
0 Kudos
Message 3 of 3
(5,674 Views)