LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI 5.5.1. Compiler Error (more info)

Dear Chris, I'm using LabWindows CVI 5.5.1 (not the patched version of CVI 5.5).
Please find attached the sample source module that reproduces the problem (?) together with the the Build Errors window contents.

Does CVI 6.0 compile this module?

Thank you!
Download All
0 Kudos
Message 1 of 7
(3,385 Views)
Sorry, but nothing obvious jumps out at me.
It compiles ok for me, and I am not too sure I understand the error in relation to the source you provided.

Do you have any include files in the source ?
Could you post the complete scratch.c file (please do that in a comment if you can rather a new message, it creates more work for the NI Guys, better to keep it all in the same thread).

Sorry, not much use to you at the moment,

Chris
0 Kudos
Message 2 of 7
(3,385 Views)
Dear Chris, you can reproduce the problem with the simple source module attached.

Please find the source and project files. In the
source file you can find additional notes on the problem.

Kind Regards
Download All
0 Kudos
Message 3 of 7
(3,385 Views)
First off, apologies since it didn't compile for me. I didn't get any errors when I pasted it into the interactive execution window for some reason.

But, saying that, looking at the error, is it not saying that you cannot assign a value of 5.0 since that is not a constant, (i.e. a float).

If the value that you wanted to assign is indeed a float, do you not have to cast that as well.

I.e.

unsigned char test2 = (unsigned char) (const) 5.0;
which is same as:
unsigned char test2 = (unsigned char) 5;

Chris
0 Kudos
Message 4 of 7
(3,385 Views)
Now we have replicated the problem. We weren't exactly sure as to how the code was being used. We didn't know the code was placed above the main function or any other subroutines. It does seems to be an error in the compiler, and we have passed this on to the development team. We noticed that there are two ways to work around this. One is to place the lines within a subroutine. Like so:

int main ()
{
unsigned char test1 = (signed char)5.0;
unsigned char test2 = (unsigned char)5.0;
signed char test3 = (signed char)5.0;
signed char test4 = (unsigned char)5.0;




return 0;
}

The other is to take out all of the decimals. This clears up the errors as well.

unsigned char test1 = (signed char)5;
unsigned char test2 = (unsigned char)5;
/* Compile errors: why? */
signed char test3 = (signed char)5;
signed char test4 = (unsigned char)5; /* Compile errors: why? */

int main ()
{




return 0;
}

These error also only occurred on 5.5.1 and 6.0 and not 5.5 or 5.0
I don't know what revision this will be fixed in.......
0 Kudos
Message 5 of 7
(3,385 Views)
Thank you very much for your help.
The following file shows how I will implement the workarounds.

Kind Regards
Giovanni
0 Kudos
Message 7 of 7
(3,385 Views)
Now we have replicated the problem. We didn't know the code was placed above the main function or any other subroutines. It does seems to be an error in the compiler, and we have passed this on to the development team. We noticed that there are two ways to work around this. One is to place the lines within a subroutine. Like so:

int main ()
{
unsigned char test1 = (signed char)5.0;
unsigned char test2 = (unsigned char)5.0;
signed char test3 = (signed char)5.0;
signed char test4 = (unsigned char)5.0;




return 0;
}

The other is to take out all of the decimals. This clears up the errors as well.

unsigned char test1 = (signed char)5;
unsigned char test2 = (unsigned char)5; /* Compile errors: why? */
signed char test3 = (signed
char)5;
signed char test4 = (unsigned char)5; /* Compile errors: why? */

int main ()
{




return 0;
}

These error also only occurred on 5.5.1 and 6.0 and not 5.5 or 5.0
I don't know what revision this will be fixed in.......
0 Kudos
Message 6 of 7
(3,385 Views)