看代码方便多了
printf("Hello World!");
2013年7月14日 13:44
$ sudo brew link node Error: Cowardly refusing to `sudo brew link` You can use brew with sudo, but only if the brew executable is owned by root. However, this is both not recommended and completely unsupported so do so at your own risk.
解决办法
$ sudo chown -R root /usr/local
2013年7月13日 23:39
sudo port -f uninstall installed
sudo rm -rf /opt/local sudo rm -rf /Applications/DarwinPorts sudo rm -rf /Applications/MacPorts sudo rm -rf /Library/LaunchDaemons/org.macports.* sudo rm -rf /Library/Receipts/DarwinPorts*.pkg sudo rm -rf /Library/Receipts/MacPorts*.pkg sudo rm -rf /Library/StartupItems/DarwinPortsStartup sudo rm -rf /Library/Tcl/darwinports1.0 sudo rm -rf /Library/Tcl/macports1.0 sudo rm -rf ~/.macports
2013年5月30日 22:37
在公司比较闲,让帮忙改一个奇怪的crash,没有任何log,才搞半天,发现是由于LoadLevelAsync 的Thread Loading,在乱七八糟的android机器上出现问题了,空指针,访问没有loading完的Additive场景里的东西。
下面的代码在Galaxy S4上直接crash,而且没有任何log,太恶心人了,如果项目代码一大堆,用最原始的排除法也让你累吐血
public class Boot : MonoBehaviour { class TestNULL { public void Test() { Debug.Log("########## Test"); } } TestNULL _test = null; void Start () { _test.Test(); //没有NullPointer异常?! }
整理了下,写了个Unity Plugin,准确定位空指针crash
void print_stack(void* ptr) { ucontext_t *ucontext = (ucontext_t*)ptr; sigcontext& sig = ucontext->uc_mcontext; gprintf("reg[fp]: %p", sig.arm_fp); gprintf("reg[ip]: %p", sig.arm_ip); gprintf("reg[sp]: %p", sig.arm_sp); gprintf("reg[lr]: %p", sig.arm_lr); gprintf("reg[pc]: %p", sig.arm_pc); if(hasMono) { MonoDomain* domain = mono_get_root_domain(); mono_thread_attach(domain); gprintf("mono trace:"); gprintf("%s", mono_pmip((void*)sig.arm_pc)); MonoJitInfo* jit = mono_jit_info_table_find(domain, (char*)sig.arm_pc); if(jit) { uint32_t code_offset = (uint32_t)((uint8_t*)sig.arm_pc - (uint8_t*)jit->code_start); MonoDebugSourceLocation* source = mono_debug_lookup_source_location (jit->method, code_offset, domain); if (source) gprintf("\t %s:%d", source->source_file, source->row); } } } void signal_handler(int signum, siginfo_t *info, void * ptr) { if (info->si_addr == NULL) { gprintf("================NullPointerException Begin===================="); gprintf("\n"); print_stack(ptr); gprintf("\n"); gprintf("================NullPointerException End===================="); } else { gprintf("================UnKnownException Begin===================="); gprintf("\n"); print_stack(ptr); gprintf("\n"); gprintf("================UnKnownException End===================="); } signal(signum, SIG_DFL); //kill(getpid(), signum); }
2013年5月11日 11:01
测试了下TreeView,还不错
control.treeView:setRootVisible(true) local rootNode = control.treeView:getRoot() rootNode:add(TreeNode:new("Test1")) rootNode:add(TreeNode:new("Test2")) rootNode:add(TreeNode:new("Test3")) rootNode:getChild(0):add(TreeNode:new("Test4")) rootNode:getChild(1):add(TreeNode:new("中文"))
2013年5月04日 11:53
sem_open无法在Mac Store App中使用,会被sandbox denied,需要额外的权限,为保险起见,还是不要使用,免得被Apple拒了
以下代码无法通过
#include <semaphore.h> sem_t * pSemaphore = sem_open(name, O_CREAT, 0777, 1); if (pSemaphore == (sem_t *)SEM_FAILED) { //... }
用pthread_mutex替代
#include <pthread.h> pthread_mutex_t* pSemaphore = (pthread_mutex_t *)BL_MALLOC(sizeof(pthread_mutex_t)); int ret = pthread_mutex_init(pSemaphore, NULL); if (ret != 0) { //... }
2013年5月04日 01:15
Hybrid封装,纯Lua实现,继续完善
iOS同样效果,自适应窗口
require "editor/BaseControl" -------------------------------------------- DebugInfoControl = class("DebugInfoControl", function(parent) return BaseControl.create("DebugInfo.layout", parent) end) DebugInfoControl.__index = DebugInfoControl function DebugInfoControl.create(parent) local control = DebugInfoControl.new(parent) control.textbox= GUICast:toTextBox(control:getWidget("_Main")) control.frames = 0 control.timer = 0 control:registerEvent("Event_Update", control.update) return control end function DebugInfoControl:update(delta) self.frames = self.frames+1 self.timer = self.timer+delta if self.timer > 0.5 then self.textbox:setCaption(string.format("FPS:%d", self.frames / self.timer)) self.frames = 0 self.timer = 0 end end