[vs12] 0.7 warnings

Started by SDH, 02 February 2015, 10:24:36

SDH

Visual Studio 2013
tgui 0.7 (latest from github)
sfml 2.2 (latest from https://www.nightlybuilds.ch)
cmake 2.8

Release Build:

Code (cpp) Select
1>------ Build started: Project: ZERO_CHECK, Configuration: Release Win32 ------
1>  Checking Build System
1>  CMake does not need to re-run because C:/Users/SHADOW/Desktop/TGUI-0.7-dev/bin/CMakeFiles/generate.stamp is up-to-date.
1>  CMake does not need to re-run because C:/Users/SHADOW/Desktop/TGUI-0.7-dev/bin/src/TGUI/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: tgui, Configuration: Release Win32 ------
2>  Building Custom Rule C:/Users/SHADOW/Desktop/TGUI-0.7-dev/src/TGUI/CMakeLists.txt
2>  CMake does not need to re-run because C:\Users\SHADOW\Desktop\TGUI-0.7-dev\bin\src\TGUI\CMakeFiles\generate.stamp is up-to-date.
2>  Button.cpp
2>  Canvas.cpp
2>  ChatBox.cpp
2>  Checkbox.cpp
2>  ChildWindow.cpp
2>  ClickableWidget.cpp
2>  Clipboard.cpp
2>..\..\..\src\TGUI\Clipboard.cpp(86): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\string.h(112) : see declaration of 'strcpy'
2>  ComboBox.cpp
2>  Container.cpp
2>  EditBox.cpp
2>  Global.cpp
2>  Grid.cpp
2>  Gui.cpp
2>  Knob.cpp
2>  Label.cpp
2>  Layout.cpp
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xmemory0(532): warning C4503: 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Insert_hint' : decorated name length exceeded, name was truncated
2>          with
2>          [
2>              _Kty=tgui::Widget *
2>  ,            _Ty=std::map<tgui::LayoutChangeTrigger,std::map<const tgui::Layout *,std::function<void (void)>,std::less<const tgui::Layout *>,std::allocator<std::pair<const tgui::Layout *const ,std::function<void (void)>>>>,std::less<tgui::LayoutChangeTrigger>,std::allocator<std::pair<const tgui::LayoutChangeTrigger,std::map<const tgui::Layout *,std::function<void (void)>,std::less<const tgui::Layout *>,std::allocator<std::pair<const tgui::Layout *const ,std::function<void (void)>>>>>>>
2>  ,            _Pr=std::less<tgui::Widget *>
2>  ,            _Alloc=std::allocator<std::pair<tgui::Widget *const ,std::map<tgui::LayoutChangeTrigger,std::map<const tgui::Layout *,std::function<void (void)>,std::less<const tgui::Layout *>,std::allocator<std::pair<const tgui::Layout *const ,std::function<void (void)>>>>,std::less<tgui::LayoutChangeTrigger>,std::allocator<std::pair<const tgui::LayoutChangeTrigger,std::map<const tgui::Layout *,std::function<void (void)>,std::less<const tgui::Layout *>,std::allocator<std::pair<const tgui::Layout *const ,std::function<void (void)>>>>>>>>>
2>          ]
2>  ListBox.cpp
2>  MenuBar.cpp
2>  MessageBox.cpp
2>  Panel.cpp
2>  Generating Code...
2>  Compiling...
2>  Picture.cpp
2>  ProgressBar.cpp
2>  RadioButton.cpp
2>  Scrollbar.cpp
2>  Signal.cpp
2>  Slider.cpp
2>  SpinButton.cpp
2>  Tab.cpp
2>  TextBox.cpp
2>..\..\..\src\TGUI\TextBox.cpp(424): warning C4244: '=' : conversion from 'float' to 'unsigned int', possible loss of data
2>  Texture.cpp
2>  TextureManager.cpp
2>  ThemeFileParser.cpp
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(836): warning C4503: 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Insert_hint' : decorated name length exceeded, name was truncated
2>          with
2>          [
2>              _Kty=std::string
2>  ,            _Ty=std::map<std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>,std::less<std::string>,std::allocator<std::pair<const std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>>>>
2>  ,            _Pr=std::less<std::string>
2>  ,            _Alloc=std::allocator<std::pair<const std::string,std::map<std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>,std::less<std::string>,std::allocator<std::pair<const std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>>>>>>
2>          ]
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(836): warning C4503: 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Insert_at' : decorated name length exceeded, name was truncated
2>          with
2>          [
2>              _Kty=std::string
2>  ,            _Ty=std::map<std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>,std::less<std::string>,std::allocator<std::pair<const std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>>>>
2>  ,            _Pr=std::less<std::string>
2>  ,            _Alloc=std::allocator<std::pair<const std::string,std::map<std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>,std::less<std::string>,std::allocator<std::pair<const std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>>>>>>
2>          ]
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(836): warning C4503: 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Insert_nohint' : decorated name length exceeded, name was truncated
2>          with
2>          [
2>              _Kty=std::string
2>  ,            _Ty=std::map<std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>,std::less<std::string>,std::allocator<std::pair<const std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>>>>
2>  ,            _Pr=std::less<std::string>
2>  ,            _Alloc=std::allocator<std::pair<const std::string,std::map<std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>,std::less<std::string>,std::allocator<std::pair<const std::string,std::vector<std::pair<std::string,std::string>,std::allocator<std::pair<std::string,std::string>>>>>>>>
2>          ]
2>  Tooltip.cpp
2>  Transformable.cpp
2>  Widget.cpp
2>  AnimatedPicture.cpp
2>  Slider2d.cpp
2>  SpriteSheet.cpp
2>  Generating Code...
2>     Creating library C:/Users/SHADOW/Desktop/TGUI-0.7-dev/bin/lib/Release/tgui.lib and object C:/Users/SHADOW/Desktop/TGUI-0.7-dev/bin/lib/Release/tgui.exp
2>  tgui.vcxproj -> C:\Users\SHADOW\Desktop\TGUI-0.7-dev\bin\lib\Release\tgui.dll
3>------ Build started: Project: ALL_BUILD, Configuration: Release Win32 ------
3>  Building Custom Rule C:/Users/SHADOW/Desktop/TGUI-0.7-dev/CMakeLists.txt
3>  CMake does not need to re-run because C:\Users\SHADOW\Desktop\TGUI-0.7-dev\bin\CMakeFiles\generate.stamp is up-to-date.
3>  Build all projects
4>------ Skipped Build: Project: INSTALL, Configuration: Release Win32 ------
4>Project not selected to build for this solution configuration
========== Build: 3 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========


If you have no time then i can repair most of those warnings.

texus

I really don't care about these conversion warnings. Once in a while I boot up my windows to fix them (because only VS gives these warnings). But you can expect more of these when I push new code.

The "decorated name length exceeded, name was truncated" warning comes from the layouts. This part has to be rewritten anyway. It's possible that the warning will remain after the rewrite though, so feel free to look at what is causing it and if it can be easily fixed.

And then there is the strcpy warning which has bothered me quite a lot since in some cases VS turns that into an error instead of a warning. But the secure version is only available in visual studio. What do you think is best here, leave it like it is, or put an ifdef around it and use strcpy on all compilers and just use strcpy_s in VS?

Feel free to fix these warnings if you want to, I don't find them important enough to boot my windows.

SDH

Clipboard.cpp
- changed:
    strcpy(pchData, m_contents.toAnsiString().c_str());
    to:
    strcpy_s(pchData, sizeof(pchData), m_contents.toAnsiString().c_str());

Layout.cpp
- added: #pragma warning(disable: 4503)

TextBox.cpp
- changed:
    m_lineHeight = m_font->getLineSpacing(m_textSize);
    to:
    m_lineHeight = static_cast<unsigned int>(m_font->getLineSpacing(m_textSize));

ThemeFileParser.cpp
- added: #pragma warning(disable: 4503)

EDIT:
succesfully compiled without warnings.

texus

The strcpy_s function only exists in Visual Studio, so this code won't compile in MinGW.

It would also be easier if you would send diff files instead of entire files. That will allow me to more easily integrate the changes. If you would be able to use git and send me a file created like "git diff > changes.diff" then all I have to do is run "git apply" to make the changes here.

This is less important for small changes like this, but if you start make bigger changes then I guess I should make the commits in your name. So what name and email address do you want me to commit these with?

SDH

#4
okay, i'll add ifdef around it.
i have no github acc, wait a while i'll create one.

EDIT:
https://github.com/texus/TGUI/pull/34