
#include <cstdio>
请注意,上述声明与此声明之间存在差异:
#include <stdio.h>
第一个将所有内容放在“std”命名空间中,第二个放在“std”命名空间中.所以我使用第一个.
下面是我在aix6.1上使用g 4.4.6编译的代码: –
#include <cstdarg> //< va_List#include <cstdio> //< vsnprintf()#include "virtual_utils.h"@R_403_6889@space VS{const char* format_str( const char* str,... ) throw(){ static char buf[10][1024]; static unsigned long buf_no = 0; char* cur_buf = buf[ ++buf_no % 10 ]; buf_no %= 10; va_List vl; va_start( vl,str );#ifdef _MSC_VER std::_vsnprintf( cur_buf,sizeof(buf),str,vl );#else std::vsnprintf( cur_buf,vl );#endif return cur_buf;}} //< @R_403_6889@space VS 这些是我得到的以下错误: –
virtual_utils.C: In function 'const char* VS::format_str(const char*,...)':virtual_utils.C:28: error: 'vsnprintf' is not a member of 'std'
编辑:
修改上面的代码以删除#include“virtual_utils.h”并添加一个main(),它为compiles with a warning under gcc4.3.4 on Ideone和cleanly under gcc4.5.1.
以上是内存溢出为你收集整理的c – 为什么编译此代码会产生错误?全部内容,希望文章能够帮你解决c – 为什么编译此代码会产生错误?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)