Macos 我可以采取哪些步骤来删除代码中的错误?
我以以下方式在I/O工具包驱动程序模板中编写代码:Macos 我可以采取哪些步骤来删除代码中的错误?,macos,cocoa,iokit,Macos,Cocoa,Iokit,我以以下方式在I/O工具包驱动程序模板中编写代码: #include <IOKit/IOService.h> class com_osxkernel_driver_IOKitTest : public IOService { OSDeclareDefaultStructors(com_osxkernel_driver_IOKitTest) public: virtual bool init (OSDictionary* dictionary = NUL
#include <IOKit/IOService.h>
class com_osxkernel_driver_IOKitTest : public IOService
{
OSDeclareDefaultStructors(com_osxkernel_driver_IOKitTest)
public:
virtual bool init (OSDictionary* dictionary = NULL);
virtual void free (void);
virtual IOService* probe (IOService* provider, SInt32* score);
virtual bool start (IOService* provider);
virtual void stop (IOService* provider);
};
#include "IOKitTest.h"
#include <IOKit/IOLib.h>
#define super IOService
OSDefineMetaClassAndStructors(com_osxkernel_driver_IOKitTest, IOService)
bool com_osxkernel_driver_IOKitTest::init (OSDictionary* dict)
{
bool res = super::init(dict);
IOLog("IOKitTest::init\n");
return res;
}
void com_osxkernel_driver_IOKitTest::free(void)
{
IOLog("IOKitTest::free\n");
super::free();
}
IOService* com_osxkernel_driver_IOKitTest::probe (IOService* provider, SInt32* score)
{
IOService *res = super::probe(provider, score);
IOLog("IOKitTest::probe\n");
return res;
}
bool com_osxkernel_driver_IOKitTest::start (IOService *provider)
{
bool res = super::start(provider);
IOLog("IOKitTest::start\n");
return res;
}
void com_osxkernel_driver_IOKitTest::stop (IOService *provider)
{
IOLog("IOKitTest::stop\n");
super::stop(provider);
}
#包括
类com_osxkernel_driver_IOKitTest:public IOService
{
OSDeclaredFaultStructors(com_osxkernel_driver_IOKitTest)
公众:
虚拟bool init(OSDictionary*dictionary=NULL);
虚拟无空洞(void);
虚拟IOService*探测器(IOService*提供程序,SInt32*分数);
虚拟bool启动(IOService*提供程序);
虚拟无效停止(IOService*提供程序);
};
#包括“IOKitTest.h”
#包括
#定义超级IOService
OSDefineMetaClassAndStructors(com_osxkernel_driver_IOKitTest,IOService)
bool com_osxkernel_驱动程序_IOKitTest::init(OSDictionary*dict)
{
bool res=super::init(dict);
IOLog(“IOKitTest::init\n”);
返回res;
}
void com_osxkernel_driver_IOKitTest::free(void)
{
IOLog(“IOKitTest::free\n”);
super::free();
}
IOService*com\u osxkernel\u driver\u IOKitTest::probe(IOService*provider,SInt32*score)
{
IOService*res=super::probe(提供者,分数);
IOLog(“iokitest::probe\n”);
返回res;
}
bool com_osxkernel_driver_IOKitTest::start(IOService*提供程序)
{
bool res=super::start(提供程序);
IOLog(“IOKitTest::start\n”);
返回res;
}
void com_osxkernel_driver_IOKitTest::stop(IOService*提供程序)
{
IOLog(“IOKitTest::stop\n”);
超级::停止(提供者);
}
当我构建此代码时,会出现四个错误:
程序中的杂散'\357'
程序中的杂散'\277'
程序中的杂散'\274'
如果发生这样的
错误'\something'
错误,您的代码中有一个无法编译的字符,您通常无法看到它们。它们通常来自出错的复制和粘贴
只需删除有错误的行并重新写入即可。不要复制粘贴或其他任何东西
我把那部分代码用十六进制编辑器打开。因此,您可以看到这些错误的来源
对于任何使用KATE(KDE高级文本编辑器)的人,我都可以通过打开导致错误的文件并取消选中“工具”菜单下的“添加字节顺序标记(BOM)”选项来修复类似的“错误”。取消选中此设置后,文件将不会显示为已更改,因此需要实际保存(Ctrl+S)文件。重新编译时,错误将消失。您需要改进问题的格式,目前无法阅读。谢谢ChriatoferEliasson@MedetiNaveenKumar如果答案解决了您的问题,请确保您将其标记为已接受。如果没有,你需要提供更多信息。这是我很久以来看到的最简洁、最彻底的答案。干得好。谢谢Matthias Bauch。以上信息对我非常有用。不客气。如果它帮助你考虑接受它。要执行此操作,请单击问题旁边的复选标记。嗨,朋友,我成功构建了上述代码,但问题是执行。我无法调试您的IOKit代码。事实上,这是我第一次听说IOKit;-)我只能回答你的问题,因为这与IOKit毫无关系。你应该问另一个问题。