Warning and review notes fixes.

WITH_WINRT -> ENABLE_WINRT_MODE;
Some temporary char* replaced with Ptr<char>;
Build fix for regular WIN32;
Windows Platform SDK and MSVC search added to cmake;
Warinig fixes.
This commit is contained in:
Alexander Smorkalov
2013-07-29 04:38:18 -07:00
parent e03ffde346
commit 63786c389f
9 changed files with 89 additions and 46 deletions

View File

@@ -3,7 +3,7 @@ ocv_add_module(core ${ZLIB_LIBRARIES})
ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
if (HAVE_WINRT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"C:/Program Files/Windows Kits/8.0/References/CommonConfiguration/Neutral\" /AI\"C:/Program Files/Microsoft Visual Studio 11.0/VC/vcpackages\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"${WINDOWS_SDK_PATH}/References/CommonConfiguration/Neutral\" /AI\"${VISUAL_STUDIO_PATH}/vcpackages\"")
endif()
if(HAVE_CUDA)

View File

@@ -68,7 +68,7 @@ namespace
~DIR()
{
if (ent.d_name)
free((void*)ent.d_name);
delete[] ent.d_name;
}
#endif
};
@@ -80,12 +80,11 @@ namespace
#ifdef HAVE_WINRT
cv::String full_path = cv::String(path) + "\\*";
size_t size = mbstowcs(NULL, full_path.c_str(), full_path.size());
wchar_t* wfull_path = (wchar_t*)malloc((size+1)*sizeof(wchar_t));
cv::Ptr<wchar_t> wfull_path = new wchar_t[size+1];
wfull_path[size] = 0;
mbstowcs(wfull_path, full_path.c_str(), full_path.size());
dir->handle = ::FindFirstFileExW(wfull_path, FindExInfoStandard,
&dir->data, FindExSearchNameMatch, NULL, 0);
free(wfull_path);
#else
dir->handle = ::FindFirstFileExA((cv::String(path) + "\\*").c_str(),
FindExInfoStandard, &dir->data, FindExSearchNameMatch, NULL, 0);
@@ -107,7 +106,7 @@ namespace
return 0;
}
size_t asize = wcstombs(NULL, dir->data.cFileName, 0);
char* aname = (char*)malloc((asize+1)*sizeof(char));
char* aname = new char[asize+1];
aname[asize] = 0;
wcstombs(aname, dir->data.cFileName, asize);
dir->ent.d_name = aname;
@@ -148,11 +147,10 @@ static bool isDir(const cv::String& path, DIR* dir)
WIN32_FILE_ATTRIBUTE_DATA all_attrs;
#ifdef HAVE_WINRT
size_t size = mbstowcs(NULL, path.c_str(), path.size());
wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t));
cv::Ptr<wchar_t> wpath = new wchar_t[size+1];
wpath[size] = 0;
mbstowcs(wpath, path.c_str(), path.size());
::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs);
free(wpath);
#else
::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs);
#endif

View File

@@ -89,15 +89,14 @@ std::wstring GetTempPathWinRT()
std::wstring GetTempFileNameWinRT(std::wstring prefix)
{
wchar_t guidStr[120];
GUID* g = 0x00;
g = new GUID;
CoCreateGuid(g);
wchar_t guidStr[40];
GUID g;
CoCreateGuid(&g);
wchar_t* mask = L"%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x";
swprintf(&guidStr[0],mask, 120, g->Data1,g->Data2,g->Data3,UINT(g->Data4[0]),
UINT(g->Data4[1]),UINT(g->Data4[2]),UINT(g->Data4[3]),UINT(g->Data4[4]),
UINT(g->Data4[5]),UINT(g->Data4[6]),UINT(g->Data4[7]));
delete g;
swprintf(&guidStr[0], sizeof(guidStr)/sizeof(wchar_t), mask,
g.Data1, g.Data2, g.Data3, UINT(g.Data4[0]), UINT(g.Data4[1]),
UINT(g.Data4[2]), UINT(g.Data4[3]), UINT(g.Data4[4]),
UINT(g.Data4[5]), UINT(g.Data4[6]), UINT(g.Data4[7]));
return prefix + std::wstring(guidStr);
}
@@ -389,7 +388,7 @@ string tempfile( const char* suffix )
{
#ifdef HAVE_WINRT
std::wstring temp_dir = L"";
wchar_t* opencv_temp_dir = _wgetenv(L"OPENCV_TEMP_PATH");
const wchar_t* opencv_temp_dir = _wgetenv(L"OPENCV_TEMP_PATH");
if (opencv_temp_dir)
temp_dir = std::wstring(opencv_temp_dir);
#else
@@ -413,11 +412,10 @@ string tempfile( const char* suffix )
DeleteFileW(temp_file.c_str());
size_t asize = wcstombs(NULL, temp_file.c_str(), 0);
char* aname = (char*)malloc((asize+1)*sizeof(char));
Ptr<char> aname = new char[asize+1];
aname[asize] = 0;
wcstombs(aname, temp_file.c_str(), asize);
fname = std::string(aname);
free(aname);
RoUninitialize();
#else
char temp_dir2[MAX_PATH + 1] = { 0 };
@@ -804,6 +802,10 @@ cvGetModuleInfo( const char* name, const char **version, const char **plugin_lis
}
#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
#ifdef HAVE_WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID );
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )

View File

@@ -1,3 +1,7 @@
#ifdef HAVE_WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
#include "test_precomp.hpp"
CV_TEST_MAIN("cv")