在 iOS 应用中使用宏 SEC_IS_BEING_DEBUGGED_RETURN_NIL
Using the Macro SEC_IS_BEING_DEBUGGED_RETURN_NIL in iOS app
我了解了下面的一段代码,据称可以在一定程度上防止Method Swizzling。
#ifndef DEBUG
SEC_IS_BEING_DEBUGGED_RETURN_NIL();
#endif
但是在我的项目中加入测试时,出现错误。
Implicit declaration of function 'SEC_IS_BEING_DEBUGGED_RETURN_NIL' is
invalid in C99
有人可以帮我解决这个错误吗,如果我需要为此包含任何库头的话。
我不打算回答我自己的问题。从上面的评论中,我搜索了任何此类实现。并找到了这个 In a GitHub Project。 NSObject
属于哪一类
也许,它会对 future
中的任何人有所帮助。
#define SEC_IS_BEING_DEBUGGED_RETURN_NIL() size_t size = sizeof(struct kinfo_proc); \
struct kinfo_proc info; \
int ret, name[4]; \
memset(&info, 0, sizeof(struct kinfo_proc)); \
name[0] = CTL_KERN; \
name[1] = KERN_PROC; \
name[2] = KERN_PROC_PID; \
name[3] = getpid(); \
if ((ret = (sysctl(name, 4, &info, &size, NULL, 0)))) { \
if (ret) return nil; \
} \
if (info.kp_proc.p_flag & P_TRACED) return nil
感谢制作者
// Created by Derek Selander on a happy day. //
// Copyright (c)
// 2013 Derek Selander. All rights reserved. //
我了解了下面的一段代码,据称可以在一定程度上防止Method Swizzling。
#ifndef DEBUG
SEC_IS_BEING_DEBUGGED_RETURN_NIL();
#endif
但是在我的项目中加入测试时,出现错误。
Implicit declaration of function 'SEC_IS_BEING_DEBUGGED_RETURN_NIL' is invalid in C99
有人可以帮我解决这个错误吗,如果我需要为此包含任何库头的话。
我不打算回答我自己的问题。从上面的评论中,我搜索了任何此类实现。并找到了这个 In a GitHub Project。 NSObject
也许,它会对 future
中的任何人有所帮助。
#define SEC_IS_BEING_DEBUGGED_RETURN_NIL() size_t size = sizeof(struct kinfo_proc); \
struct kinfo_proc info; \
int ret, name[4]; \
memset(&info, 0, sizeof(struct kinfo_proc)); \
name[0] = CTL_KERN; \
name[1] = KERN_PROC; \
name[2] = KERN_PROC_PID; \
name[3] = getpid(); \
if ((ret = (sysctl(name, 4, &info, &size, NULL, 0)))) { \
if (ret) return nil; \
} \
if (info.kp_proc.p_flag & P_TRACED) return nil
感谢制作者
// Created by Derek Selander on a happy day. //
// Copyright (c)
// 2013 Derek Selander. All rights reserved. //