LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Function name must be a valid C identifier

I'm looking at the Racal ri1260 driver.  It was built with Labwindows/CVI 5.1.  I have Labwindows/CVI 7.1 on Win2K and I've tried to rebuild the dll.  I have a problem in that several panels point to the same function.

For example:  1260-35A 4-wire MUX, 1260-30B 2x20 MUX Relay, 1260-30C 4x10 MUX Relay, 1260-30D 8x5 MUX Relay all call ri1260_30_operate_single.  This gives an error in the ODL and link step that says that ri1260_30_operate_single is multiply defined.

Here is the definition of the function.
ViStatus _VI_FUNC ri1260_30_operate_single (ViSession vi, ViInt16 module, ViInt16 operation, ViInt16 group, ViInt16 relay)

If I try to "edit Node" on these panels, they each display "30_operate_single" as the name.  If I try to change the name and resave it (e.g. 30_operate_single_A) , I get an error "Function name must be a valid C identifier".

So, it looks like there are two problems.  The functions are multiply defined, and the function names start with digits.

I'm wondering if this is operator error on my part, or if things have changed from Labwindows/CVI 5 to 7, to cause these errors?

0 Kudos
Message 1 of 8
(4,694 Views)

Hello,

I'm not too sure about that specific driver -- on our website (www.ni.com/drivers) I am finding drivers certified for CVI 6.  Maybe something changed from version 5 to 6 with this driver.  Feel free to let us know if this solves the problem.

Regards,

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 8
(4,659 Views)
Thank you Travis,
I will download the NI version of the driver tomorrow and see if it is different from the one I got directly from the Racal site yesterday.  I'll let you know.
M.


0 Kudos
Message 3 of 8
(4,654 Views)
fwiw,
 
I looked at www.ni.com/drivers.  The driver there exibits similar problems.  Here's how to demonstrate the problem:
 

I downloaded the Racal Dana 1260 switch driver for LabWindows/CVI 6.0 (ri1260.zip).  It contains four files:  ri1260c, ri1260.doc, ri1260.fp, and ri1260.h.
 
I clicked on the .fp file, got into CVI, created a dll project,  and tried to create the dynamic link library.
 
I got a warning that a bunch of functions are not using the _stddecl interface.
 
I got the big grey  "Error generating type library message" panel.
 
I ran the mktyplib.exe manually and got the following error message.
   "fatal error M0001: Syntax error near line 242 column 15:  duplicate definition"
Here is where the first error occurs in the odl file.  (I presume because rd1260_50_operate_single is defined twice).
...
  [helpcontext(27), entry("rd1260_50_operate_single"), helpstring("1260-50A 8 MUX Relay")]
  int __cdecl rd1260_50_operate_single(
   [in] int instrumentID,
   [in] int moduleAddress,
   [in] int operation,
   [in] int MUXNumber,
   [in] int relayNumber);
  [helpcontext(28), entry("rd1260_50_operate_single"), helpstring("1260-50B 16 MUX Relay")]
  int __cdecl rd1260_50_operate_single(
   [in] int instrumentID,
   [in] int moduleAddress,
   [in] int operation,
   [in] int MUXNumber,
   [in] int relayNumber);
 
0 Kudos
Message 4 of 8
(4,629 Views)

Hello!

One thing to check is that you are using the c calling convention in the DLL you are creating.  In CVI choose "Options->Build Options" and change the Default Calling convention to __cdecl.  This will probably clear up your first error, which may clear up the other.

As always, feel free to let us know the outcome of this!



Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 5 of 8
(4,606 Views)
Thanks Travis,

Yes.  I bet choosing the C interface will clear up the  warnings. 

The other problem is in the code from the NI repository.  The function "rd1260_50_operate_single" is defined twice through the .fp file, once for the "A" version and once for the "B" version.  This gives the link error.

As compared with the driver downloaded from RACAL this week, the NI repository version fixes some duplicate name problems, just not all.   The NI version uses the following convention (which isn't in the files I downloaded from RACAL):  The 30A,B,C,D switches each have their own functions, named  rd1260_30_operate_single, rd1260_30_1_operate_single, rd1260_30_2_operate_single and rd1260_30_3_operate_single.

To fix the NI version you would have to keep rd1260_50_operate_single and add rd1260_50_1_operate_single.  I can see my way through the problem, I'm just a little surprised that I can't download source and readily build it, without edits.

M.
0 Kudos
Message 6 of 8
(4,597 Views)

Hello,

I do not think that the function is multiply defined in the 6.0 instr driver.  I noticed that it is #define(d) in 2 locations -- i.e. if you examine the ri1260.h file, and search for that function, you will find it referenced in a few places -- 1 is in a comment, 2 are in these statements:

#define rd1260_50_1_operate_single rd1260_50_operate_single
#define rd1260_50_2_operate_single rd1260_50_operate_single

and only once as a function declaration.  I was able to load the instrument driver, call one of the functions and return without link errors. 

 

I suspect that there might be a problem with how the driver was loaded into the CVI platform.  The driver should be an out of the box solution -- I agree that it is desirable to have such a driver.  I recommend that you examine your system and make sure that you do not have the driver loaded in multiple places or have multiple versions of the driver loaded in the project.  You may want to start with a completely new project, and load the instrument driver (in CVI select Instrument... and first unload all instruments, then load the 1260 driver.  Then create a basic c file to reference one of the functions so that it actually gets linked by the compiler. 

Hopefully this helps! Have a great weekend, and please let us know how things go.



Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 7 of 8
(4,578 Views)
Travis,
 
Thanks for your help.  I think have an explanation.
 
I created my project by clicking on the .fp file and then choosing OPTIONS>>Create DLL Project...
When I create the project this way I get "Add Type Lib To DLL = True" by default.
 
When I created the project your way (by beginning with an empty project, loading the .FP, etc.) the default is "Add Type Lib To DLL=FALSE"
 
In this case, its not OK to Add the Type Library resource from the .FP to the DLL. 
 
Thank again!
M.
 
0 Kudos
Message 8 of 8
(4,569 Views)