#pragma warning for C4503 and /bigobj

This commit is contained in:
Fm 2016-06-22 17:51:06 +03:00
parent 63c2465f32
commit f3b0159ef1
4 changed files with 19 additions and 12 deletions

View File

@ -78,6 +78,12 @@ elseif (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # else if using Visu
message(STATUS "Enabling SSE2 instructions")
add_definitions(-DDLIB_HAVE_SSE2)
endif()
# By default Visual Studio does not support .obj files with more than 65k sections
# Code generated by file_to_code_ex and code using DNN module can have them
# this flag enables > 65k sections, but produces .obj files that will not be readable by
# VS 2005
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()

View File

@ -10,10 +10,6 @@ PROJECT(examples)
include(../dlib/cmake)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
# Tell CMake to compile a program. We do this with the ADD_EXECUTABLE()
# statement which takes the name of the output executable and then a list of
# .cpp files to compile. Here each example consists of only one .cpp file but
@ -35,13 +31,6 @@ ENDMACRO()
# The deep learning toolkit requires a C++11 capable compiler.
if (COMPILER_CAN_DO_CPP_11)
# Visual Studio Specific
# DNN module produces long type names for NN definitions - disable this warning for MSVC
# And when compiling Debug mode file will be too big for normal compilation
if (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(STATUS "Enabling Visual Studio specific flags for DNN")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4503 /bigobj")
endif()
add_example(dnn_mnist_ex)
add_example(dnn_mnist_advanced_ex)
add_example(dnn_inception_ex)

View File

@ -23,10 +23,17 @@
the IEEE Conference on Computer Vision and Pattern Recognition. 2015.
*/
// DNN module uses template-based network declaration that leads to very long
// type names. Visual Studio will produce Warning C4503 in such cases
#ifdef _MSC_VER
# pragma warning( disable: 4503 )
#endif
#include <dlib/dnn.h>
#include <iostream>
#include <dlib/data_io.h>
using namespace std;
using namespace dlib;
@ -84,7 +91,7 @@ int main(int argc, char** argv) try
// Make an instance of our inception network.
net_type net;
cout << "The net has " << net.num_layers << " layers in it." << endl;
cout << net << endl;
// cout << net << endl;
cout << "Traning NN..." << endl;

View File

@ -10,6 +10,11 @@
- Accessing and configuring layers in a network
*/
// DNN module uses template-based network declaration that leads to very long
// type names. Visual Studio will produce Warning C4503 in such cases
#ifdef _MSC_VER
# pragma warning( disable: 4503 )
#endif
#include <dlib/dnn.h>
#include <iostream>