![](/img/trans.png)
[英]structure repetition error compiling C WinSock code in visual studio 2010
[英]Visual Studio 2010 Compiling C code
我有以下代碼片段。 這是Visual Studio 2010中的ac文件。如果我嘗試使用以下行進行編譯:int hello = 10; 評論它會編譯就好了。 如果我在其中注釋該行,則不會編譯。 我是否缺少某些內容,或者不應該使用Visual Studio 2010編譯C代碼。 如果這是Visual Studio的問題,誰能推薦一個我可以用C編寫的易於使用的IDE /編譯器。
謝謝
int* x = (int*) calloc(1, sizeof(int));
*x = 5;
//int hello = 10;
printf("Hello World! %i", *x);
getchar();
與C99或C ++不同,C89中的非聲明(例如*x = 5;
)之后不能有聲明(例如int hello = 10;
)。
MSVC 2010仍然不支持C99。
您仍然可以在編碼后聲明變量。 只需將“ yourProject.c”文件更改為“ yourProject.cpp”,它將可以正常工作。
在C中類型轉換malloc
返回指針是一種不好的做法,並且結果不確定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.