Dealing with compiler warnings
Posted: 24.01.2009, 17:07
Compiling the qt4 version using gcc 4.3.2, I get the following warning messages:
The attached diff file solves a fair fraction of these: I didn't bother with the globular file because of Fridger's upcoming revision, and I didn't look at the qt-specific code. As for the remainder, I'm not entirely sure how to go about fixing them. The remaining warnings are
It would be nice to know whether the patch breaks anything though.
Code: Select all
celengine/astro.cpp: In member function ‘const char* astro::Date::toCStr(astro::Date::Format) const’:
celengine/astro.cpp:529: warning: deprecated conversion from string constant to ‘char*’
celengine/astro.cpp:532: warning: deprecated conversion from string constant to ‘char*’
celengine/astro.cpp:535: warning: deprecated conversion from string constant to ‘char*’
celengine/astro.cpp:525: warning: ‘strftime_format’ may be used uninitialized in this function
celengine/astro.cpp: At global scope:
celengine/astro.cpp:109: warning: ‘MonthAbbrList’ defined but not used
In file included from celengine/command.cpp:12:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
celengine/globular.cpp:56: warning: ‘bool decreasing(const GBlob&, const GBlob&)’ defined but not used
celengine/image.cpp: In function ‘void PNGReadData(png_struct*, png_byte*, png_size_t)’:
celengine/image.cpp:632: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
celengine/image.cpp: In function ‘Image* LoadPNGImage(const std::string&)’:
celengine/image.cpp:658: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
celengine/marker.cpp: In member function ‘void MarkerRepresentation::render(float) const’:
celengine/marker.cpp:154: warning: enumeration value ‘Crosshair’ not handled in switch
celengine/rendcontext.cpp: In member function ‘virtual void GLSLUnlit_RenderContext::makeCurrent(const Mesh::Material&)’:
celengine/rendcontext.cpp:832: warning: unused variable ‘bumpTex’
celengine/rendcontext.cpp:833: warning: unused variable ‘specTex’
celengine/rendcontext.cpp:834: warning: unused variable ‘emissiveTex’
celengine/render.cpp: In function ‘void renderCrosshair(float, double)’:
celengine/render.cpp:10405: warning: comparison between signed and unsigned integer expressions
/usr/include/c++/4.3/bits/stl_algo.h: In member function ‘void Renderer::renderPlanet(Body&, Point3f, float, float, const Observer&, const Quatf&, float, float)’:
/usr/include/c++/4.3/bits/stl_algo.h:1844: warning: array subscript is above array bounds
celengine/skygrid.cpp: In member function ‘std::string SkyGrid::longitudeLabel(int, int) const’:
celengine/skygrid.cpp:310: warning: deprecated conversion from string constant to ‘char*’
celengine/skygrid.cpp:318: warning: deprecated conversion from string constant to ‘char*’
In file included from celestia/celestiacore.cpp:45:
celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
celestia/celestiacore.cpp: In member function ‘void CelestiaCore::mouseButtonDown(float, float, int)’:
celestia/celestiacore.cpp:684: warning: suggest parentheses around && within ||
celestia/celestiacore.cpp: In member function ‘void CelestiaCore::renderOverlay()’:
celestia/celestiacore.cpp:3662: warning: comparison with string literal results in unspecified behaviour
celestia/celestiacore.cpp: At global scope:
celestia/celestiacore.cpp:3108: warning: ‘void displayAcronym(Overlay&, char*)’ defined but not used
celestia/configfile.cpp: In function ‘CelestiaConfig* ReadCelestiaConfig(std::string, CelestiaConfig*)’:
celestia/configfile.cpp:282: warning: suggest braces around empty body in an ‘else’ statement
In file included from celestia/eclipsefinder.h:18,
from celestia/eclipsefinder.cpp:18:
celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
celestia/favorites.cpp: In function ‘void WriteFavoritesList(FavoritesList&, std::ostream&)’:
celestia/favorites.cpp:138: warning: enumeration value ‘PhaseLock_Old’ not handled in switch
celestia/favorites.cpp:138: warning: enumeration value ‘Chase_Old’ not handled in switch
celestia/favorites.cpp:138: warning: enumeration value ‘Unknown’ not handled in switch
celestia/imagecapture.cpp: In function ‘void PNGWriteData(png_struct*, png_byte*, png_size_t)’:
celestia/imagecapture.cpp:113: warning: ignoring return value of ‘size_t fwrite(const void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
celestia/scriptmenu.cpp: In member function ‘virtual bool ScriptScanner::process(const std::string&)’:
celestia/scriptmenu.cpp:53: warning: comparison between signed and unsigned integer expressions
In file included from celestia/url.cpp:23:
celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/celx.cpp:51:
celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/celx_frame.cpp:15:
celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/celx_object.cpp:21:
celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
celestia/celx_object.cpp: In function ‘int object_orbitvisibility(lua_State*)’:
celestia/celx_object.cpp:202: warning: deprecated conversion from string constant to ‘char*’
celestia/celx_object.cpp:204: warning: deprecated conversion from string constant to ‘char*’
celestia/celx_object.cpp:206: warning: deprecated conversion from string constant to ‘char*’
In file included from celestia/celx_observer.cpp:17:
celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtappwin.h:16,
from celestia/qt/qtmain.cpp:24:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
celestia/qt/qtmain.cpp:29: warning: ‘description’ defined but not used
In file included from celestia/qt/qtappwin.h:16,
from celestia/qt/qtappwin.cpp:44:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from ./celestia/url.h:22,
from celestia/qt/qtbookmark.cpp:22:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtglwidget.cpp:40:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtappwin.h:16,
from celestia/qt/qtpreferencesdialog.cpp:28:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
celestia/qt/qtpreferencesdialog.cpp:439: warning: unused parameter ‘m’
celestia/qt/qtpreferencesdialog.cpp:451: warning: unused parameter ‘s’
celestia/qt/qtpreferencesdialog.cpp:463: warning: unused parameter ‘l’
celestia/qt/qtpreferencesdialog.cpp:475: warning: unused parameter ‘pathIdx’
celestia/qt/qtpreferencesdialog.cpp:492: warning: unused parameter ‘dts’
celestia/qt/qtpreferencesdialog.cpp:34: warning: ‘FilterOtherLocations’ defined but not used
In file included from celestia/qt/qtcelestialbrowser.cpp:33:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtdeepskybrowser.cpp:32:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtsolarsystembrowser.cpp:22:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtselectionpopup.cpp:15:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
celestia/qt/qtcolorswatchwidget.cpp:17: warning: unused parameter ‘parent’
In file included from celestia/qt/qttimetoolbar.cpp:16:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtcelestiaactions.cpp:15:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qteventfinder.cpp:30:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtsettimedialog.cpp:23:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtappwin.h:16,
from moc_qtappwin.cpp:10:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
In file included from celestia/qt/qtglwidget.h:19,
from moc_qtglwidget.cpp:10:
./celestia/celestiacore.h:38: warning: declaration ‘class astro::Date’ does not declare anything
The attached diff file solves a fair fraction of these: I didn't bother with the globular file because of Fridger's upcoming revision, and I didn't look at the qt-specific code. As for the remainder, I'm not entirely sure how to go about fixing them. The remaining warnings are
Code: Select all
celengine/globular.cpp:56: warning: ‘bool decreasing(const GBlob&, const GBlob&)’ defined but not used
celengine/image.cpp: In function ‘void PNGReadData(png_struct*, png_byte*, png_size_t)’:
celengine/image.cpp:632: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
celengine/image.cpp: In function ‘Image* LoadPNGImage(const std::string&)’:
celengine/image.cpp:658: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
celengine/marker.cpp: In member function ‘void MarkerRepresentation::render(float) const’:
celengine/marker.cpp:154: warning: enumeration value ‘Crosshair’ not handled in switch
/usr/include/c++/4.3/bits/stl_algo.h: In member function ‘void Renderer::renderPlanet(Body&, Point3f, float, float, const Observer&, const Quatf&, float, float)’:
/usr/include/c++/4.3/bits/stl_algo.h:1844: warning: array subscript is above array bounds
celestia/favorites.cpp: In function ‘void WriteFavoritesList(FavoritesList&, std::ostream&)’:
celestia/favorites.cpp:138: warning: enumeration value ‘PhaseLock_Old’ not handled in switch
celestia/favorites.cpp:138: warning: enumeration value ‘Chase_Old’ not handled in switch
celestia/favorites.cpp:138: warning: enumeration value ‘Unknown’ not handled in switch
celestia/imagecapture.cpp: In function ‘void PNGWriteData(png_struct*, png_byte*, png_size_t)’:
celestia/imagecapture.cpp:113: warning: ignoring return value of ‘size_t fwrite(const void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
celestia/qt/qtmain.cpp:29: warning: ‘description’ defined but not used
celestia/qt/qtpreferencesdialog.cpp:439: warning: unused parameter ‘m’
celestia/qt/qtpreferencesdialog.cpp:451: warning: unused parameter ‘s’
celestia/qt/qtpreferencesdialog.cpp:463: warning: unused parameter ‘l’
celestia/qt/qtpreferencesdialog.cpp:475: warning: unused parameter ‘pathIdx’
celestia/qt/qtpreferencesdialog.cpp:492: warning: unused parameter ‘dts’
celestia/qt/qtpreferencesdialog.cpp:34: warning: ‘FilterOtherLocations’ defined but not used
celestia/qt/qtcolorswatchwidget.cpp:17: warning: unused parameter ‘parent’
It would be nice to know whether the patch breaks anything though.