MSVC中的错误? [英] Bug in MSVC ?

查看:109
本文介绍了MSVC中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在MSVC 2003或2005下编译以下代码。


..................... ............................. ..................... ....................

#include< stdio.h>


struct _MyStruct;

typedef struct _MyStruct MyStruct;


typedef void(* funcType)(MyStruct *);


struct _MyStruct {double x;};

void MyFunc(MyStruct * theStruct){printf("%f",theStruct-> x);}


int main(){

MyStruct A;

Ax = 100.0;

funcType f =& MyFunc;

f(& A);


}

..................... ............................. ..................... .........


在gcc下,没问题。

解决方案

< blockquote> Dnia 2007年5月18日02:50:05 -0700,Nindi napisa3(a):


我无法在MSV下编译以下代码C 2003或2005.


................................. ................. ................................. .......

#include< stdio.h>


struct _MyStruct;

typedef struct _MyStruct MyStruct;


typedef void(* funcType)(MyStruct *);


struct _MyStruct {double x;};


void MyFunc(MyStruct * theStruct){printf(" %f",theStruct-> x);}


int main(){

MyStruct A;

Ax = 100.0;

funcType f =& MyFunc;

f(& A);


}

............................................... ... .............................

在gcc下,没问题。



从编译器中给我们一些错误。我看不到返回0在这里,但不要

知道你是忘了在这里写的还是只是片段。


-

SirMike - http://www.sirmike.org


C让你轻松拍摄自己的脚; C ++让它变得更难,但是当你这样做时,它会让你的整条腿感到震惊。 - Bjarne Stroustrup


5月18日上午10点50分,Nindi< Nind ... @ yahoo.co.ukwrote:


我无法在MSVC 2003或2005下编译以下代码。


................. ................................. ................. .......................

#include< stdio.h>


struct _MyStruct;

typedef struct _MyStruct MyStruct;


typedef void(* funcType)(MyStruct *);


struct _MyStruct {double x;};


void MyFunc(MyStruct * theStruct){printf("%f",theStruct-> x);}


int main(){

MyStruct A;

Ax = 100.0;

funcType f =& MyFunc ;

f(& A);


}


.......... ........................................ .......... ...................


在gcc下,没问题。



你得到了什么编译错误?


我刚刚在MS VC ++ 2003上编译它并编译得很好。


5月18日,10:59,SirMike< sirm ... @ FUCKSPAMMERSpoczta.onet.plwrote:


Dnia 2007年5月18日02:50:05 -0700,Nindi napisa3(a):



我无法得到以下代码在MSVC 2003或2005下编译。


................... ............................... ................... ....... * ...............

#include< stdio.h>


struct _MyStruct;

typedef struct _MyStruct MyStruct;


typedef void(* funcType)(MyStruct *);


struct _MyStruct {double x;};


void MyFunc(MyStruct * theStruct){printf("%f",theStruct-> x);}


int main(){

MyStruct A;

Ax = 100.0;

funcType f =& MyFunc;

f(& A);


}

..................... ............................. ..................... ..... * ....


在gcc下,没问题。



从编译器中给我们一些错误。我看不到返回0在这里,但不要

知道你是忘了在这里写的还是只是片段。


-

SirMike -http://www.sirmike.org


C让你轻松拍摄自己的脚; C ++让它变得更难,但是当你这样做时,它会让你的整条腿感到震惊。 - Bjarne Stroustrup-隐藏引用文字 -


- 显示引用文字 -




我不确定是否返回是必要的主要,但我将它的

更好的形式加入。

以下是2003年的错误

... ................................................ ...... .........

------构建开始:项目:TestStruct,配置:调试Win32

------


编译......

main.c

c:\ TEMP \ TestBed \ TestStruct \ main.c(18 ):错误C2275:''funcType'':

非法使用此类型作为表达式

c:\ TEMP \ TestBed \TestStruct \ main.c (8):见声明

''funcType''

c:\ TEMP \ TestBed \ TestStruct \ main.c(18):错误C2146:语法错误:

在标识符f之前缺少'';''

c:\ TEMP \ TestBed \ TestStruct \ main.c(18 ):错误C2144:语法错误:

''<未知>''前面应加''< Unknown>''

c:\ TEMP \ TestBed\TestStruct\main.c(18):错误C2144:语法错误:

''<未知>''前面应加''< Unknown>''
c:\ TEMP \ TestBed \TestStruct\main.c(18):错误C2143:语法错误:

在''标识符'之前缺少'';''

c:\ TEMP \ TestBed\TestStruct\main.c(18):错误C2065:''f'':未声明

标识符

c:\ TEMP \ TestBed \ TestStruct \ main.c(18):警告C4047:''='':''int''

的间接等级不同来自''void(__ cdecl *)(MyStruct *)''

c:\ TEMP \ TestBed \ TestStruct \ main.c(19):错误C2063:''f'':不是

函数


构建日志保存在file:// c:\ Temp\TestBed\TestStruct\Debug

\BuildLog.htm"

TestStruct - 7个错误,1个警告


........................................... ....... ........

并且在gcc 3.2.3(mingw)下没有窥视,它编译并且工作正常。


I cannot get the following code to compile under MSVC 2003 or 2005.

.................................................. .........................................
#include<stdio.h>

struct _MyStruct;
typedef struct _MyStruct MyStruct;

typedef void (*funcType)(MyStruct *);

struct _MyStruct {double x;};
void MyFunc(MyStruct *theStruct){printf(" %f ",theStruct->x);}

int main () {
MyStruct A;
A.x = 100.0;
funcType f=&MyFunc;
f(&A);

}
.................................................. ..............................

Under gcc , no problem .

解决方案

Dnia 18 May 2007 02:50:05 -0700, Nindi napisa3(a):

I cannot get the following code to compile under MSVC 2003 or 2005.

.................................................. ........................................
#include<stdio.h>

struct _MyStruct;
typedef struct _MyStruct MyStruct;

typedef void (*funcType)(MyStruct *);

struct _MyStruct {double x;};
void MyFunc(MyStruct *theStruct){printf(" %f ",theStruct->x);}

int main () {
MyStruct A;
A.x = 100.0;
funcType f=&MyFunc;
f(&A);

}
.................................................. .............................

Under gcc , no problem .

Give us some errors from the compiler. I see no "return 0" here but don''t
know whether you forgot to write it here or is just the snippet.

--
SirMike - http://www.sirmike.org

C makes it easy to shoot yourself in the foot; C++ makes it harder, but
when you do, it blows away your whole leg. - Bjarne Stroustrup


On May 18, 10:50 am, Nindi <Nind...@yahoo.co.ukwrote:

I cannot get the following code to compile under MSVC 2003 or 2005.

.................................................. ........................................
#include<stdio.h>

struct _MyStruct;
typedef struct _MyStruct MyStruct;

typedef void (*funcType)(MyStruct *);

struct _MyStruct {double x;};

void MyFunc(MyStruct *theStruct){printf(" %f ",theStruct->x);}

int main () {
MyStruct A;
A.x = 100.0;
funcType f=&MyFunc;
f(&A);

}

.................................................. .............................

Under gcc , no problem .

What compilation errors are you getting?

I just compiled it on MS VC++ 2003 and it compiles fine.


On 18 May, 10:59, SirMike <sirm...@FUCKSPAMMERSpoczta.onet.plwrote:

Dnia 18 May 2007 02:50:05 -0700, Nindi napisa3(a):


I cannot get the following code to compile under MSVC 2003 or 2005.

.................................................. ..........................*...............
#include<stdio.h>

struct _MyStruct;
typedef struct _MyStruct MyStruct;

typedef void (*funcType)(MyStruct *);

struct _MyStruct {double x;};

void MyFunc(MyStruct *theStruct){printf(" %f ",theStruct->x);}

int main () {
MyStruct A;
A.x = 100.0;
funcType f=&MyFunc;
f(&A);

}
.................................................. ..........................*....

Under gcc , no problem .


Give us some errors from the compiler. I see no "return 0" here but don''t
know whether you forgot to write it here or is just the snippet.

--
SirMike -http://www.sirmike.org

C makes it easy to shoot yourself in the foot; C++ makes it harder, but
when you do, it blows away your whole leg. - Bjarne Stroustrup- Hide quoted text -

- Show quoted text -



I am not sure whether return is neccessary in main, but I aggree its
better form to put it in.
Here are the errors under 2003
.................................................. ............
------ Build started: Project: TestStruct, Configuration: Debug Win32
------

Compiling...
main.c
c:\TEMP\TestBed\TestStruct\main.c(18) : error C2275: ''funcType'' :
illegal use of this type as an expression
c:\TEMP\TestBed\TestStruct\main.c(8) : see declaration of
''funcType''
c:\TEMP\TestBed\TestStruct\main.c(18) : error C2146: syntax error :
missing '';'' before identifier ''f''
c:\TEMP\TestBed\TestStruct\main.c(18) : error C2144: syntax error :
''<Unknown>'' should be preceded by ''<Unknown>''
c:\TEMP\TestBed\TestStruct\main.c(18) : error C2144: syntax error :
''<Unknown>'' should be preceded by ''<Unknown>''
c:\TEMP\TestBed\TestStruct\main.c(18) : error C2143: syntax error :
missing '';'' before ''identifier''
c:\TEMP\TestBed\TestStruct\main.c(18) : error C2065: ''f'' : undeclared
identifier
c:\TEMP\TestBed\TestStruct\main.c(18) : warning C4047: ''='' : ''int''
differs in levels of indirection from ''void (__cdecl *)(MyStruct *)''
c:\TEMP\TestBed\TestStruct\main.c(19) : error C2063: ''f'' : not a
function

Build log was saved at "file://c:\Temp\TestBed\TestStruct\Debug
\BuildLog.htm"
TestStruct - 7 error(s), 1 warning(s)

.................................................. ........
And under gcc 3.2.3 (mingw) not a peep, it compiles and works fine.


这篇关于MSVC中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆