-
iOS
- Pro-tip: you can use the xcrun tool to easily refer to the proper version of clang (i.e. the one from the iOS toolchain): CC=$(shell xcrun -sdk iphoneos -find clang)
- Linking Against stdlibc++
A static library project (for iOS) with an Objective-C interface uses internally a C++ implementation.
When creating an Objective-C application, I would like to keep the app project as less modified as possible when linking against the static library. Well, usually this requires the application to be linked against the C++ library, that is libstdc++.
It seems, I have these alternatives:
1) rename the main.m file to main.mm and the app project automatically links agains libstdc++.
2) add to "Other Linker Flags" the option "-lstdc++" of the target settings of the application.
3) add the libstdc++.dylib in the "Link Binary With Libraries" section of the Build Phases in the target settings of the application.
(可能是iOS6的原因,我加入libstdc++.6.dylib才可编译通过,老版本未试验)
I prefer option 1) as it seems the most reliable method, for several reasons.
However, is there any better way, possibly one which does not require to add/change application build settings or modifies any of the applications source files?
雑多
- To display macros which aren't strings, stringify the macro:
#define STRINGIFY(s) XSTRINGIFY(s)
#define XSTRINGIFY(s) #s
#define ADEFINE 23
#pragma message ("ADEFINE=" STRINGIFY(ADEFINE))
If you have/want boost, you can use boost stringize to do it for you:
#include <boost/preprocessor/stringize.hpp>
#define ADEFINE 23
#pragma message ("ADEFINE=" BOOST_PP_STRINGIZE(ADEFINE))
- 制作patch文件
diff -Naur 旧的目录 新的目录 > patch文件
- iOS
- 用NSPR在iOS上输出Log文件
PRLogModuleInfo* test_lm;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPathEnv = [NSString stringWithFormat:@"%@%@/%@",@"NSPR_LOG_FILE=",documentsDirectory, @"test.log"];
if(putenv("NSPR_LOG_MODULES=all:5") != 0){
fprintf(stderr, "putenv failed\n");
}
if(putenv((char*)logPathEnv.UTF8String) != 0){
fprintf(stderr, "putenv failed\n");
}
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
test_lm = PR_NewLogModule("test");
PR_LOG(test_lm, PR_LOG_MIN, ("logfile: test log message"));
PR_Cleanup();
- 用NSPR在iOS上输出Log文件
- VI光标移动
ctrl-o 和 ctrl-i 光标上下次位置
g; 和 g, 编辑过的上下位置