fix #3758, also change some declarations to C99 style