kum*_*mar -1 macos cocoa iokit
我通过以下方式在I/O Kit驱动程序模板中编写代码:
#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);
}
Run Code Online (Sandbox Code Playgroud)
当我构建此代码时,我得到四个错误:
stray '\357' in programstray '\277' in programstray '\274' in program你能看到错误吗?
Mat*_*uch 10
你能看到错误吗?
不,但编译器可以.Xcode会向您展示.
我将您的代码粘贴到一个新项目中并编译它:

所有三个杂散字符都在代码的相同部分.
如果stray '\something'发生这样的错误,您的代码中有一个无法编译的字符,而您通常无法看到它们.它们通常来自错误的复制和粘贴.
只需删除带有错误的行并再次写入.不要复制和粘贴或任何东西.
我拿了那部分代码并在十六进制编辑器中打开它.所以你可以看到这些错误的来源.

| 归档时间: |
|
| 查看次数: |
348 次 |
| 最近记录: |