---
title: "编译错误C3163：_vsprintf的属性声明不兼容"
author: "luck_donkey"
date: "2011-02-13T20:07:47Z"
tags: ["C", "C#", "C++", "Microsoft", "VC++"]
categories: ["编程语言"]
slug: "c3163-vsprintf"
draft: false
lastmod: "2011-02-13T20:08:17Z"
id: 905380
url: "https://luck-donkey.iteye.com/blog/905380"
---

# 编译错误C3163：\_vsprintf的属性声明不兼容

## 问题

在昨天用 VS2008 和最新的 V7.1SDK 编译程序的 ZLIB 时候，出现了一个错误：

38&gt; C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include\\stdio.h(358) : error C3163: '\_vsnprintf': attributes inconsistent with previous declaration  
38&gt;        C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include\\stdio.h(350) : see declaration of '\_vsnprintf'

 

看了一下，粗看之下，感觉到很奇怪，这可是 VC 自己的头文件的定义，难道还有错误，在发布的时候都没有发现吗？转念一想，编译别的程序的时候也用到了这个文件，怎么没有报错呢？这其中有什么古怪？

 

## **解决办法**

在 Gooogle 上用“ error C3163: '\_vsnprintf': attributes inconsistent with previous declaration ”作为关键词搜索了一下，很快找到了这个网址： [http://hi.baidu.com/johnllon/blog/item/8b22a5074a8d06ce7b8947e0.html](http://hi.baidu.com/johnllon/blog/item/8b22a5074a8d06ce7b8947e0.html) ，描述了与我遇到的相同的问题，作者遇到了这个问题后已经解决了，原因是：

  在使用 vsnprintf 这个函数的 cpp 文件中，包含了 # define vsnprintf \_vsnprintf 的定义。在以前版本的 vc 中，没有定义 vsnprintf ，只定义 \_vsnprintf 。而在 2008 版本中，添加了 vsnprintf 的定义。因此在编译的时候导致出现了上述错误。

解决的办法是针对 vc2008 前的 vc 定义宏：

#if (\_MSC\_VER &lt; 1500)  
#define vsnprintf \_vsnprintf  
#endif