10-14-2009 03:32 PM
I don't want to add stuff to my code that is only to stop popups while debugging, so I don't want to add this junk:
int bPrevBreak;
// don't break on errors, but save previous state
bPrevBreak = SetBreakOnLibraryErrors (FALSE);
everywhere in my code because CVI won't let me universally disable the non-fatal runtime error popups.
So, how can this crapola be disabled?????
PS I know there are no real errors in the places this thinks there are run time errors, so it is just annoying.
10-14-2009 03:53 PM - edited 10-14-2009 03:59 PM
Ken:
I don't think non-fatal runtime errors are only for debugging. I would never just ignore all non-fatal runtime errors. I would either plan on handling them in my code or letting CVI handle them. In a lot of programs, users can do some pretty unexpected things that could cause errors. I would want to know what that error is, and not just ignore it. I've never been able to anticipate everything a user will do with any code I create.
I would advise against disabling all errors unless you have an error handler that checks every error.
But, if you want to disable all errors, what's wrong with one line of code?
SetBreakOnLibraryErrors(FALSE);
You don't need to save the previous state if you never plan on returning to it. Just put this line at the start of your code, set it to FALSE once, and forget it. But if you do, it may make some field failures harder to troubleshoot. I've seen enough bugs in my own code to appreciate any hints I can get about what went wrong.
10-14-2009 04:09 PM - edited 10-14-2009 04:10 PM
The problem is that this is not getting anything that is an actual error.
I have x = strtol( y_string, NULL, 16);
in my code,
the string is FFFF, and no problems with the array or other variables,
when I step over this the value of x is correct,
this is a part of code that is called a lot, and really makes attempts to debug the area I am working on frustrating, since this is not a problem in my code.
There are a couple of other spots in my code that have the same break issue, but I don't want to waste my time looking at that, since I need to work on the area in the code I am working on, and also since it seems this breaks for no viable reason.
I put the code you mentioned in my code previously, but it did nothing, so I'm thinking I'll need to put this whereever CVI thinks there is a problem, which doesn't exist.
Also, I don't want to check out files (I'm using Clearcase) that are not part of something I'm working on. Then I have to have an admin get rid on the branch. The error is in a file I am not editing.
I'm not saying the runtime errors are something for debugging, but I'm trying to debug some code, and CVI is giving me these popups in some other area of the code that I am not changing. That is making my debugging take five or so extra minutes everytime I loop through the code.
10-14-2009 04:43 PM
Ken:
Are you saying that you get a non-fatal error at the following line, with y_string = "FFFF"?
x = strtol( y_string, NULL, 16);
I don't see a problem. What is the error?
Do you get the same error with different values of y_string?
Is x a long?
Is y_string a NULL terminated string? How does it get its value?
I'm puzzled that you're still breaking on errors after you set break on error FALSE. That may have something to do with the organization of the project and where the file you're debugging fits into it.
Do you have all of the source files for your project? Are you calling functions from a DLL or linking an object file?
Does the file you're debugging include the project's main()?
What version of CVI are you using?
10-14-2009 04:58 PM
Are you saying that you get a non-fatal error at the following line, with y_string = "FFFF"? yes
x = strtol( y_string, NULL, 16);
I don't see a problem. What is the error? errno == 34, Range error (in hex: 46 46 46 46 00, in ascii FFFF)
Do you get the same error with different values of y_string? I am not sure
Is x a long? int, but in another line of code with the same problem, that return variable is a long, and it has the same error.
Is y_string a NULL terminated string? How does it get its value? yes, see above, copied from one array to another in a for loop, with the null added at the end
I'm puzzled that you're still breaking on errors after you set break on error FALSE. Me too, but not surprised. That may have something to do with the organization of the project and where the file you're debugging fits into it.
Do you have all of the source files for your project? Yes. Are you calling functions from a DLL or linking an object file? No.
Does the file you're debugging include the project's main()? Yes.
What version of CVI are you using? 9.0
I also get the error with a free( ), which is in a bit of a complicated area, so I am apprehensive to remove it. The error is attempting to free apointer to freed memory.
10-14-2009 05:11 PM
How are you declaring y_string?
How are you populating y_string?
Can you run the following code as a stand-alone project and see if you get any run-time errors?
#include <utility.h>
#include <ansi_c.h>
main()
{
long x;
char y_string[80];
strcpy(y_string,"FFFF");
x = strtol( y_string, NULL, 16);
printf("Value of 0x%s = %d\n"
"Press any key...", y_string, x);
GetKey();
}
10-16-2009 11:15 AM
char y_string[500] = {'\0'};
for (index = count; index > 0; index--)
{
y_string[index] = hex_from_file[index];
}
y_string[count+1] = '\0';
[basically]
I run your example and don't get any errors.
10-16-2009 11:50 AM
In stepping through this code, the string is
BBCCDDEE \0
and when I step through the code the results ends up being 0x7FFFFFFF
I found some other threads in the forums, and from the strtol( ) panel
it looks like the conversion thinks this is larger than the max value, and therefore sets it to the max integer value, and sets the errno flag.
Weeding through CVIs "help" I found another strto function strtoul, where the U is working with unsigned values and the range for this is 0x00000000 to 0xFFFFFFFF, which is what I need. I also changed the variable to be an unsigned long, rather than an int.
So, I guess I need to weed through my code an dfind out what the heck these other errors are. Probably a solution for the rest of them, too.
Thanks AI S for your help, and sticking with me on this.