我有我與Visual Studio 2005構建源在另一個項目中獲得內置使用Visual Studio 6VS2005:如何將項目編譯爲VS6?
因爲通過引入新的_s
-functions這將導致潛在的錯誤也使用項目Security Enhancements in the CRT不存在於VS6中。
爲了確保我的源代碼在VS6中也能很好地運行,同時不需要單獨安裝VS6,我想用VS2005編譯它們,但禁用新的安全功能(由Security Enhancements引入)。那可能嗎?
我有我與Visual Studio 2005構建源在另一個項目中獲得內置使用Visual Studio 6VS2005:如何將項目編譯爲VS6?
因爲通過引入新的_s
-functions這將導致潛在的錯誤也使用項目Security Enhancements in the CRT不存在於VS6中。
爲了確保我的源代碼在VS6中也能很好地運行,同時不需要單獨安裝VS6,我想用VS2005編譯它們,但禁用新的安全功能(由Security Enhancements引入)。那可能嗎?
的answer given by Sergius啓發了我運行一個自制方法:
secure.c
#if (_MSC_VER >= 1400)
for i in $(cat secure_functions.txt)
do
grep -rn --exclude "secure.c" -w $i path/to/sources
done
備份:如果有人要做到這一點,這裏的安全功能列表:
_access_s
_waccess_s
_malloca
asctime_s
_wasctime_s
bsearch_s
_cgets_s
_cgetws_s
_chsize_s
clearerr_s
_controlfp_s
_cprintf_s
_cprintf_s_l
_cwprintf_s
_cwprintf_s_l
_cscanf_s
_cscanf_s_l
_cwscanf_s
_cwscanf_s_l
_ctime_s
_ctime32_s
_ctime64_s
_wctime_s
_wctime32_s
_wctime64_s
_ecvt_s
_fcvt_s
fopen_s
_wfopen_s
fprintf_s
_fprintf_s_l
fwprintf_s
_fwprintf_s_l
freopen_s
_wfreopen_s
fscanf_s
_fscanf_s_l
fwscanf_s
_fwscanf_s_l
_ftime_s
_ftime32_s
_ftime64_s
_gcvt_s
getenv_s
_wgetenv_s
gets_s
_getws_s
_gmtime32_s
_gmtime64_s
_itoa_s
_i64toa_s
_ui64toa_s
_itow_s
_i64tow_s
_ui64tow_s
_lfind_s
localtime_s
_localtime32_s
_localtime64_s
_lsearch_s
_ltoa_s
_ltow_s
_makepath_s
_wmakepath_s
_mbccpy_s
_mbccpy_s_l
_mbsnbcat_s
_mbsnbcat_s_l
_mbsnbcpy_s
_mbsnbcpy_s_l
mbsrtowcs_s
mbstowcs_s
_mbstowcs_s_l
memcpy_s
wmemcpy_s
memmove_s
wmemmove_s
_mktemp_s
_wmktemp_s
printf_s
_printf_s_l
wprintf_s
_wprintf_s_l
_putenv_s
_wputenv_s
qsort_s
rand_s
scanf_s
_scanf_s_l
wscanf_s
_wscanf_s_l
_searchenv_s
_wsearchenv_s
_snprintf_s
_snprintf_s_l
_snwprintf_s
_snwprintf_s_l
_snscanf_s
_snscanf_s_l
_snwscanf_s
_snwscanf_s_l
_sopen_s
_wsopen_s
_splitpath_s
_wsplitpath_s
sprintf_s
_sprintf_s_l
swprintf_s
_swprintf_s_l
sscanf_s
_sscanf_s_l
swscanf_s
_swscanf_s_l
strcat_s
wcscat_s
_mbscat_s
strcpy_s
wcscpy_s
_mbscpy_s
_strdate_s
_wstrdate_s
strerror_s
_strerror_s
_wcserror_s
__wcserror_s
_strlwr_s
_strlwr_s_l
_mbslwr_s
_mbslwr_s_l
_wcslwr_s
_wcslwr_s_l
strncat_s
_strncat_s_l
wcsncat_s
_wcsncat_s_l
_mbsncat_s
_mbsncat_s_l
strncpy_s
_strncpy_s_l
wcsncpy_s
_wcsncpy_s_l
_mbsncpy_s
_mbsncpy_s_l
_strtime_s
_wstrtime_s
strtok_s
_strtok_s_l
wcstok_s
_wcstok_s_l
_mbstok_s
_mbstok_s_l
_strupr_s
_strupr_s_l
_mbsupr_s
_mbsupr_s_l
_wcsupr_s
_wcsupr_s_l
tmpfile_s
tmpnam_s
_wtmpnam_s
_ultoa_s
_ultow_s
_umask_s
_vcprintf_s
_vcprintf_s_l
_vcwprintf_s
_vcwprintf_s_l
vfprintf_s
_vfprintf_s_l
vfwprintf_s
_vfwprintf_s_l
vprintf_s
_vprintf_s_l
vwprintf_s
_vwprintf_s_l
vsnprintf_s
_vsnprintf_s
_vsnprintf_s_l
_vsnwprintf_s
_vsnwprintf_s_l
vsprintf_s
_vsprintf_s_l
vswprintf_s
_vswprintf_s_l
wcrtomb_s
wcsrtombs_s
wcstombs_s
_wcstombs_s_l
wctomb_s
_wctomb_s_l
VS.Net和VS6使用的文件(框架,庫,組件)完全不同。儘管可以使用COM封裝器從VS6中使用一些庫,但您無法在VS.Net中獲得完整的VS6兼容性。
如果這很重要,那麼移植代碼的一次努力將是有益的。
您可以通過定義_CRT_SECURE_NO_WARNINGS
來禁用有關不安全功能的警告。你也可以爲_s函數添加一個條件編譯的包裝器:在VS2005和更高版本上使用_s函數,在其他任何使用包裝_s函數的函數中調用普通函數。
我當然知道使用安全功能的好處。但正如我所說,我的項目被用於另一個項目,該項目使用vS6進行編譯,並且**不會被移植到VS2005。 – eckes