__if_exists keyword in microsoft c++

__if_exists allows you to check a class have member or not. __if_exists用于检查类中是否存在某成员

__if_exists(class::member)

more 更多

标签: windows
日期: 2016-04-22 17:30:06, 8 years and 268 days ago

通过阅读官方手册进行学习是自我提高的捷径。

MSDN的一般结构为:

super topic
 \
  + topic - Overview -+- About
     |                |
     |                +- Using
     |                |
     |                +- Reference
     +--- relation topics

每个主题都有一个Overview,以摘要形式简单介绍主题的相关内容。

每个主题都包含: 关于about 用法using 参考reference 三部分。

  • 关于:主题相关的知识点的详细解释,需要详读。
  • 用法:包括代码片段或工程示例说明主题相关的API用法,可以结合前面的关于章节进一步理解知识点,感兴趣的部分详读并运行调试。
  • 参考:主题相关API包括函数,结构体,宏和枚举的详细文档说明,略读。

以GDI文档为例:https://msdn.microsoft.com/en-us/library/vs/alm/dd145071.aspx.aspx)

... > Archive > Graphics > Windows GDI 
-------------------------------------------+-----------------------------------
                                           |Multiple Display Monitors is ....
...                                        |
v Multiple Display Monitors                |
 v About Multiple Display Monitors         |
    The Virtual Screen                     |
    ...                                    |
 > Using Multiple Display Monitors         |
 > Multiple Display Monitors Reference     |
                                           |

顶部为其父主题,左侧为此主题的章节部分。右侧为此主题的概述。

标签: windows, manual
日期: 2016-04-15 17:30:06, 8 years and 275 days ago

逆向windows静态库

list all objs in static library 列出静态库中所有obj

lib staticlibrary.lib /List

export obj from static library 导出指定的obj

lib staticlibrary /EXTRACT:membername

disassemble obj file 反汇编obj

objdump -S membername.obj > membername.asm

标签: windows, assembly
日期: 2016-04-08 17:30:06, 8 years and 282 days ago

Objective-C 调用 Swift

Swift 类

Swift类定义前加入@objc关键字,并使类继承自NSObject

@objc class S : NSObject{
    func m() {
        print(__FUNCTION__)
    }
}

在调用Swift代码的Objc文件中加入名类似为"xxx-Swift.h"的头文件

头文件具体的名字可在 设置选项:

{project} - {targets} - {build settings} - {swift compiler - code generation} - {Objective-C Generated Interface Header Name}

objc调用swift头文件名


 #import "objc_swift-Swift.h"
int main(int argc, const char * argv[]) {
   @autoreleasepool {
        S* s = [[S alloc]init];
        [s m];
    }
    return 0;
 }

Swift 调用 Objective-C

创建桥接文件

创建桥接文件

选择Create Bridging Header

桥接文件在如下设置位置

{project} - {targets} - {build settings} - {swift compiler - code generation} - {Objective-C Bridging Header}

将要调用的ObjC类头文件import至桥接文件中

//
//  Use this file to import your target's public headers that you would like to expose to Swift.
//

 #import "O.h"

ObjC 代码

.h 文件

@interface O : NSObject
-(void)m;
@end

.m 文件

@implementation O
-(void)m {
    NSLog(@"%s", __FUNCTION__);
}
@end

swift 文件

@objc class S : NSObject{
    let o:O = O()
    func m() {
        o.m()
        print(__FUNCTION__)
    }
}

示例工程

objc-swift

标签: objc, swift, cocoa, xos
日期: 2016-04-01 17:30:06, 8 years and 289 days ago