找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 12887|回复: 2

编译时候为什么有很多warning

[复制链接]
发表于 2010-6-24 10:00:58 | 显示全部楼层 |阅读模式
我自己写了一个很简单的test程序,想看看自己编译的ace能不能用了.

代码如下:

// firstACE.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "ace/INET_Addr.h"
#include "ace/SOCK_Stream.h"
#include "ace/SOCK_Connector.h"
#include "ace/Log_Msg.h"
#include "ace/OS.h"
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{
ACE::init();
ACE_INET_Addr srvr(80,"192.168.1.119");
ACE_SOCK_Connector connector;
ACE_SOCK_Stream peer;
int ret = connector.connect(peer,srvr);
std::cout<<ACE_OS::last_error();

std::cout<<ret;
if(-1==ret)
  return 0;
int bc;
char buf[10]="sdfdf";
peer.send_n(buf,3);
bc = peer.recv(buf,sizeof(buf));
peer.close();
return 0;
}

/////////////////////////////////////////////// end
但是编译的时候出现了那么多warning,这是为什么.我网上下别人的代码编译就没那么多warning.我也看了下warning 等级大家都是 Level 3,难道真要用_CRT_SECURE_NO_WARNINGS屏蔽掉这类warning?


E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(110) : warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(79) : see declaration of 'strcat'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(120) : warning C4996: 'wcscat': This function or variable may be unsafe. Consider using wcscat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(995) : see declaration of 'wcscat'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(178) : 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.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(74) : see declaration of 'strcpy'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(188) : warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(1002) : see declaration of 'wcscpy'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(222) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(207) : see declaration of 'strdup'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(266) : warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(144) : see declaration of 'strncat'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(279) : warning C4996: 'wcsncat': This function or variable may be unsafe. Consider using wcsncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(1016) : see declaration of 'wcsncat'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(320) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(157) : see declaration of 'strncpy'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(329) : warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(1022) : see declaration of 'wcsncpy'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(513) : warning C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(166) : see declaration of 'strtok'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_string.inl(524) : warning C4996: 'wcstok': This function or variable may be unsafe. Consider using wcstok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(1027) : see declaration of 'wcstok'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdlib.inl(174) : warning C4996: 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(483) : see declaration of 'getenv'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdlib.inl(186) : warning C4996: '_wgetenv': This function or variable may be unsafe. Consider using _wdupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(891) : see declaration of '_wgetenv'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdlib.inl(197) : warning C4996: '_itoa': This function or variable may be unsafe. Consider using _itoa_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(501) : see declaration of '_itoa'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdlib.inl(210) : warning C4996: '_itow': This function or variable may be unsafe. Consider using _itow_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(878) : see declaration of '_itow'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdlib.inl(276) : warning C4996: '_mktemp': This function or variable may be unsafe. Consider using _mktemp_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\io.h(214) : see declaration of '_mktemp'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdlib.inl(287) : warning C4996: '_wmktemp': This function or variable may be unsafe. Consider using _wmktemp_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(324) : see declaration of '_wmktemp'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdlib.inl(336) : warning C4996: 'putenv': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _putenv. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(900) : see declaration of 'putenv'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_unistd.inl(60) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\io.h(315) : see declaration of 'access'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_unistd.inl(131) : warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _chdir. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\direct.h(127) : see declaration of 'chdir'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_unistd.inl(158) : warning C4996: 'rmdir': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _rmdir. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\direct.h(129) : see declaration of 'rmdir'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_unistd.inl(409) : warning C4996: 'getcwd': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getcwd. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\direct.h(121) : see declaration of 'getcwd'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_unistd.inl(1016) : warning C4996: 'swab': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _swab. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(901) : see declaration of 'swab'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_unistd.inl(1160) : warning C4996: 'unlink': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _unlink. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(290) : see declaration of 'unlink'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_sys_stat.inl(154) : warning C4996: 'mkdir': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _mkdir. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\direct.h(128) : see declaration of 'mkdir'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdio.inl(705) : warning C4996: 'freopen': This function or variable may be unsafe. Consider using freopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(245) : see declaration of 'freopen'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdio.inl(899) : warning C4996: 'tempnam': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _tempnam. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(679) : see declaration of 'tempnam'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdio.inl(1006) : warning C4996: 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345) : see declaration of 'vsprintf'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdio.inl(1058) : warning C4996: '_vsnprintf': This function or variable may be unsafe. Consider using _vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(339) : see declaration of '_vsnprintf'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_stdio.inl(1106) : warning C4996: '_vsnwprintf': This function or variable may be unsafe. Consider using _vsnwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(450) : see declaration of '_vsnwprintf'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_sys_mman.inl(110) : warning C4267: 'argument' : conversion from 'size_t' to 'DWORD', possible loss of data
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_time.inl(21) : warning C4996: 'asctime': This function or variable may be unsafe. Consider using asctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\time.h(166) : see declaration of 'asctime'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_time.inl(123) : warning C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\time.inl(88) : see declaration of 'ctime'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_time.inl(363) : warning C4996: 'gmtime': This function or variable may be unsafe. Consider using gmtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\time.inl(101) : see declaration of 'gmtime'
E:\aceLearning\ACE-5.7.8\ACE_wrappers\ace/OS_NS_time.inl(402) : warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Program Files\Microsoft Visual Studio 8\VC\include\time.inl(114) : see declaration of 'localtime'
发表于 2010-6-24 10:18:13 | 显示全部楼层
直接把4996禁用了吧。
发表于 2010-7-13 22:17:28 | 显示全部楼层
这是因为在VC2005即以后的版本中,已经不建议使用不安全的C字符串处理函数了(建议使用安全版本,就是不安全版本后面加上_s的函数版本),但是ACE目前还在使用,你可以采用两种方式,一种是为项目定义_CRT_SECURE_NO_WARNINGS宏,还有一种是楼上说的,禁止4996警告。
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-11-1 07:07 , Processed in 0.014003 second(s), 5 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表