English 中文(简体)
为什么编纂这一法典会产生错误?
原标题:Why is compiling this code producing an error?
  • 时间:2011-11-22 10:03:50
  •  标签:
  • c++
  • gcc
  • aix

我认为这是正确的主人:

  #include <cstdio>

  #include <stdio.h>

第1条将一切放在“星号”名称空间,第2版。 因此,我使用了第一个版本。

下面是我正在汇编的法典,使用g++4.4.6。

#include <cstdarg> //< va_list
#include <cstdio>  //< vsnprintf()
#include "virtual_utils.h"

namespace 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, sizeof(buf), str, vl );
#endif

  return cur_buf;
}


} //< namespace 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 

Edit: Modifying the above code to remove the #include "virtual_utils.h" and to add a main(), it compiles with a warning under gcc4.3.4 on Ideone and cleanly under gcc4.5.1.

最佳回答

查阅<代码>--save-temps,并查阅.ii。 这应当说明以什么名称空间和什么名称界定什么。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签