1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > linux c创建文件错误的是 在linux下创建一个类怎么出现会出现这种错误 我感觉是没

linux c创建文件错误的是 在linux下创建一个类怎么出现会出现这种错误 我感觉是没

时间:2020-10-25 05:58:27

相关推荐

linux c创建文件错误的是 在linux下创建一个类怎么出现会出现这种错误 我感觉是没

下面文件有KenoComm.h,KenoComm.c,b.c三个文件,还有Makefile文件.

类CKenoComm定义在KenoComm.c中,b.c调用了类CKenoComm.

我在linux下编译时,问题是

[root@localhost7.12]#make

cc-c-ob.ob.c

Infileincludedfromb.c:5:

KenoComm.h:14:parseerrorbefore"CKenoComm"

KenoComm.h:15:syntaxerrorbefore'{'token

KenoComm.h:19:warning:datadefinitionhasnotypeorstorageclass

KenoComm.h:20:parseerrorbefore'~'token

b.c:Infunction`main':

b.c:9:parseerrorbefore"a"

b.c:10:`a'undeclared(firstuseinthisfunction)

b.c:10:(Eachundeclaredidentifierisreportedonlyonce

b.c:10:foreachfunctionitappearsin.)

make:***[b.o]Error1

那位大侠能帮我解决一下吗,先谢谢了.

我的新建类的头文件是KenoComm.h

//KenoComm.h:interfacefortheCKenoCommclass.

//

//

#if!defined(AFX_KENOCOMM_H__3781E982_B927_4046_B209_1D8827A17071__INCLUDED_)

#defineAFX_KENOCOMM_H__3781E982_B927_4046_B209_1D8827A17071__INCLUDED_

#if_MSC_VER>1000

#pragmaonce

#endif//_MSC_VER>1000

#include

classCKenoComm

{

public:

voidDelPipe();

intReadPipe();

CKenoComm();

virtual~CKenoComm();

};

#endif//!defined(AFX_KENOCOMM_H__3781E982_B927_4046_B209_1D8827A17071__INCLUDED_)

我的新建类的.cpp文件为KenoComm.c

//KenoComm.c:implementationoftheCKenoCommclass.

//

//

//#include"stdafx.h"

#include"KenoComm.h"

//

//Construction/Destruction

//

CKenoComm::CKenoComm()

{

}

CKenoComm::~CKenoComm()

{

}

intCKenoComm::ReadPipe()

{

printf("ReadPipen");

return1;

}

voidCKenoComm::DelPipe()

{

printf("DelPipen");

}

我的主文件为b.c

#include"KenoComm.h"

#include

intmain(intargc,char*argv[])

{

CKenoComma;

a.DelPipe();

a.ReadPipe();

printf("HelloWorld!n");

return0;

}

我的Makefile文件为

RM=rm-f

CXX=g++

#CXXFLAGS=+DA2.0W-s

CXXFLAGS=+O3

Pipe:PipeComm

OBJS_PipeComm=b.oKenoComm.o

PipeComm:$(OBJS_PipeComm)

$(RM)$@

$(CXX)-o$@$(CXXLDFLAGS)$(OBJS_PipeComm)

clean:

$(RM)corePipeComm**.o

~

~

|

RM=rm-f

CXX=g++

#CXXFLAGS=+DA2.0W-s

CXXFLAGS=+O3

Pipe:PipeComm

OBJS_PipeComm=b.cKenoComm.c

PipeComm:$(OBJS_PipeComm)

$(RM)$@

$(CXX)-o$@$(CXXLDFLAGS)$(OBJS_PipeComm)

clean:

$(RM)corePipeComm**.o

|

你是c++程序,文件用.cpp。你用.c,编译器认为是c程序,c程序里没有class。

|

文件名改为.C或.cpp后缀,或者改makefile用-xc++编译选项指定用从c++编译器来编译.c文件

|

你用什么编辑的程序?看看是DOS格式的还是UNIX合适的?

字符好象不对。

|

我遇到过这样的问题,不过忘记怎么解决的了!不好意思,嘿嘿!

好象如楼上所说的,字符格式不对.重新输入一次试试.

|

程序没问题,makefile写错了

|

难道是要把.c改为.cpp?

linux c创建文件错误的是 在linux下创建一个类怎么出现会出现这种错误 我感觉是没有错误的 那位高手过来看看...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。