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

 2023-09-23 阅读 30 评论 0

摘要:下面文件有KenoComm.h,KenoComm.c,b.c三个文件,还有Makefile文件.类CKenoComm定义在KenoComm.c中,b.c调用了类CKenoComm.我在linux下编译时,问题是编译没有错误运行有错误怎么办?[root@localhost7.12]#makecc-c-ob.ob.cInfileincludedfromb.c:5:KenoComm.h:14:parseerror

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

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

我在linux下编译时,问题是

编译没有错误运行有错误怎么办?[root@localhost 7.12]# make

cc    -c -o b.o b.c

In file included from b.c:5:

KenoComm.h:14: parse error before "CKenoComm"

linux复制文件夹到另一个目录。KenoComm.h:15: syntax error before '{' token

KenoComm.h:19: warning: data definition has no type or storage class

KenoComm.h:20: parse error before '~' token

b.c: In function `main':

线程main java中的异常怎么解决。b.c:9: parse error before "a"

b.c:10: `a' undeclared (first use in this function)

b.c:10: (Each undeclared identifier is reported only once

b.c:10: for each function it appears in.)

linux查看文件内容命令?make: *** [b.o] Error 1

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

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

// KenoComm.h: interface for the CKenoComm class.

linux创建目录使用哪条命令、//

//

#if !defined(AFX_KENOCOMM_H__3781E982_B927_4046_B209_1D8827A17071__INCLUDED_)

#define AFX_KENOCOMM_H__3781E982_B927_4046_B209_1D8827A17071__INCLUDED_

一个意外错误使你无法创建该文件?#if _MSC_VER > 1000

#pragma once

#endif // _MSC_VER > 1000

#include

linux移动文件命令?class CKenoComm

{

public:

void DelPipe();

int ReadPipe();

CKenoComm();

virtual ~CKenoComm();

};

#endif // !defined(AFX_KENOCOMM_H__3781E982_B927_4046_B209_1D8827A17071__INCLUDED_)

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

// KenoComm.c: implementation of the CKenoComm class.

//

//

//#include "stdafx.h"

#include "KenoComm.h"

//

// Construction/Destruction

//

CKenoComm::CKenoComm()

{

}

CKenoComm::~CKenoComm()

{

}

int CKenoComm::ReadPipe()

{

printf("ReadPipen");

return 1;

}

void CKenoComm::DelPipe()

{

printf("DelPipen");

}

我的主文件为 b.c

#include "KenoComm.h"

#include

int main(int argc, char* argv[])

{

CKenoComm a;

a.DelPipe();

a.ReadPipe();

printf("Hello World!n");

return 0;

}

我的Makefile文件为

RM      = rm -f

CXX     = g++

#CXXFLAGS        = +DA2.0W -s

CXXFLAGS         = +O3

Pipe:  PipeComm

OBJS_PipeComm   = b.o KenoComm.o

PipeComm : $(OBJS_PipeComm)

$(RM)$@

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

clean:

$(RM) core PipeComm* *.o

~

~

|

RM      = rm -f

CXX     = g++

#CXXFLAGS        = +DA2.0W -s

CXXFLAGS         = +O3

Pipe:  PipeComm

OBJS_PipeComm   = b.c KenoComm.c

PipeComm : $(OBJS_PipeComm)

$(RM) $@

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

clean:

$(RM) core PipeComm* *.o

|

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

|

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

|

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

字符好象不对。

|

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

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

|

程序没问题,makefile写错了

|

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

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/3/86817.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息