2011-07-14 145 views
13

我想知道如果Microsoft Visual Studio 2010支持C99。如果不是,我如何使用標準類型intptr_tuintptr_tMicrosoft visual studio 2010支持c99嗎?

+0

[Visual Studio支持新的C/C++標準?]的可能的重複?(http://stackoverflow.com/questions/146381/visual-studio-support-for-new-cc-standards) –

+1

這是2008版,所以不是一個確切的副本。 –

+0

http://herbsutter.com/2012/05/03/reader-qa-what-about-vc-and-c99/幾乎可以說有關這個問題的一切。 –

回答

8

據我所知,Visual Studio 2010不支持C99。要使用stdint.h中的類型,你必須使用typedef。一個跨平臺的方式來做到這一點是:

#ifdef _WIN32 
typedef signed short int16_t 
#else 
#include <stdint.h> 
#endif 

也看到這個了這個問題: Visual Studio support for new C/C++ standards?

+0

我使用的印刷係數是什麼?在C99 **中,zd **適用於** 32位和64位**環境。 – thetna

+0

對不起,什麼是「印刷因素」和什麼是「zd」? –

+1

** ** intptr_t **的** zd **打印因子** ** ** **的**%** ** ** ** ** – thetna

11

的Visual Studio 2010不支持C99語法。儘管如此,stdint.h是所有C/C++編譯器中的一個非常常見的文件,它在Windows SDK(不管您使用的Visual Studio版本)中包含在Visual C++ 10.0安裝中。

stdint.h可以發現:

  • C:\ Program Files文件(x86)的\微軟的Visual Studio 10.0 \ VC \包括\

該文件確實提供了intptr_t一個typedef 。隨意在任何你喜歡的C或C++項目中使用它。

2

Microsoft C不支持C99。但是,MSVC 16(Visual Studio 2010提供的)實現了即將到來的C++ 0x標準的很大一部分。的C++ 0x是將一些從C99的標題,如stdint.hinttypes.h的 - 這就是爲什麼你得到C99的一些花絮MSVC 16

要感謝小東西(我希望MSVC支持更多的C99的編譯直C文件時)。

相關問題