[Sglib-general] sglib + MS VS.NET 2003 problem
Brought to you by:
vittek
From: David K. <kr...@at...> - 2005-12-21 16:51:15
|
Hi,=20 first of all I'd like to say thanx for creating and publishing SGLIB fo= r free, I am using it frequently in situations when I am forced to use = pure C and so far it's been doing great job=2E But today I've arrived t= o the first (quite small) problem with it=2E=20 I am using Microsoft Visual Studio =2ENET 2003=2E My problem is that th= e debug version of my program started to abort in the middle of SGLIB c= ode saying that "Run-Time Check Failure #3 - The variable '_cmpres_' is= being used without being defined=2E"=2E I've analyzed the problem care= fully and arrived to the function=20 sglib_<my_type>_find_member=20 generated by macro SGLIB_DEFINE_SORTED_LIST_FUNCTIONS=2E=20 In sglib source code it corresponds to macro SGLIB_SORTED_LIST_FIND_MEM= BER starting on line 494=2E The problem is that in some situations variable _cmpres_ is defined (li= ne 496) but not initialized and then tested by if for equality to zero= (line 498)=2E This happens if the list parameter of macro is NULL=2E I= n this case the right side of the AND (&&) operator in the middle part = of for statement (line 497) is not executed at all and hence _cmpres_ i= s not initialized and probably (as a result of some optimizations of mi= crosoft's C runtime) not defined at all=2E=20 The solution could be setting _cmpres_ to (-1) in the declaration (for= example, anything else than zero should work,obviously)=2E I don't know if SGLIB is still being actively developed (fixed) and I c= ould fix it only for my project but first anyone can arrive to the same= problem some day, and second according to license I think it's not per= fectly legal to use modified version of SGLIB in commercial project, so= I'd like to here something from author;-) Thanx for any answer=2E David K=2E |