03 2014 档案

摘要:由于公司的游戏项目比较特殊, coco2d-x 的 ios 和 android 的游戏 代码 没有采用 共享目录的开发方式。所以android 内的 c++ 游戏代码全部放在 jni 下, 这样就导致一个问题, c++ 一调整或者修改代码,一大堆的警告产生。 解决这个问题的办法:http://www.cnblogs.com/zilongshanren/archive/2012/04/28/2473282.html --让eclipse 减少语法检查,哎。。。 阅读全文
posted @ 2014-03-29 16:46 porter_代码工作者 阅读(165) 评论(0) 推荐(0) 编辑
摘要:在C中,默认的基础数据类型均为signed,现在我们以char为例,说明(signed) char与unsigned char之间的区别首先在内存中,char与unsigned char没有什么不同,都是一个字节,唯一的区别是,char的最高位为符号位,因此char能表示-128~127, unsigned char没有符号位,因此能表示0~255,这个好理解,8个bit,最多256种情况,因此无论如何都能表示256个数字。在实际使用过程种有什么区别呢?主要是符号位,但是在普通的赋值,读写文件和网络字节流都没什么区别,反正就是一个字节,不管最高位是什么,最终的读取结果都一样,只是你怎么理解最高 阅读全文
posted @ 2014-03-27 21:57 porter_代码工作者 阅读(705) 评论(0) 推荐(0) 编辑
摘要:UTF-8(8-bit Unicode Transformation Format)是一种针对Unicode的可变长度字符编码,也是一种前缀码。UTF-8使用一至六个字节为每个字符编码(尽管如此,2003年11月UTF-8被RFC 3629重新规范,只能使用原来Unicode定义的区域,U+0000到U+10FFFF,也就是说最多4位字节):128个US-ASCII字符只需一个字节编码(Unicode范围由U+0000至U+007F)。带有附加符号的拉丁文、希腊文、西里尔字母、亚美尼亚语、希伯来文、阿拉伯文、叙利亚文及它拿字母则需要两个字节编码(Unicode范围由U+0080至U+07FF) 阅读全文
posted @ 2014-03-25 22:05 porter_代码工作者 阅读(420) 评论(0) 推荐(0) 编辑
摘要:C的NULL在C语言中,我们使用NULL表示空指针,也就是我们可以写如下代码:int *i = NULL;foo_t *f = NULL;实际上在C语言中,NULL通常被定义为如下:#define NULL ((void *)0)也就是说NULL实际上是一个void *的指针,然后吧void *指针赋值给int *和foo_t *的指针的时候,隐式转换成相应的类型。而如果换做一个C++编译器来编译的话是要出错的,因为C++是强类型的,void *是不能隐式转换成其他指针类型的,所以通常情况下,编译器提供的头文件会这样定义NULL:#ifdef __cplusplus ---简称:cpp c++ 阅读全文
posted @ 2014-03-19 16:26 porter_代码工作者 阅读(85538) 评论(3) 推荐(14) 编辑
摘要:// 重启应用 public void restartApp() { Intent intent = new Intent(); // 参数1:包名,参数2:程序入口的activity intent.setClassName(getPackageName(), "包名"); PendingIntent restartIntent = PendingIntent.getActivity( getApplicationContext(), 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK); AlarmManager mgr = (Alarm.. 阅读全文
posted @ 2014-03-19 15:36 porter_代码工作者 阅读(1399) 评论(0) 推荐(0) 编辑
摘要:时常在cpp的代码之中看到这样的代码:#ifdef __cplusplusextern "C" {#endif//一段代码#ifdef __cplusplus}#endif 这样的代码到底是什么意思呢?首先,__cplusplus是cpp中的自定义宏,那么定义了这个宏的话表示这是一段cpp的代码,也就是说,上面的代码的含义是:如果这是一段cpp的代码,那么加入extern "C"{和}处理其中的代码。 要明白为何使用extern "C",还得从cpp中对函数的重载处理开始说起。在c++中,为了支持重载机制,在编译生成的汇编码中,要对函 阅读全文
posted @ 2014-03-19 14:58 porter_代码工作者 阅读(394) 评论(0) 推荐(0) 编辑
摘要:STL的排序太坑了,尤其是在VS2010上重载sort函数的第三个比较参数的时候。invalid operator #include#include#includeusing namespace std;struct Node{ int x; int y;};bool Comp(Node &a,Node &b){ if(a.x==b.x) return b.y>a.y; else return a.x>b.x;}vector node;int main(){ srand((unsigned int)time(0)); for(int i... 阅读全文
posted @ 2014-03-11 14:24 porter_代码工作者 阅读(330) 评论(0) 推荐(0) 编辑
摘要:经常遇到到问题: 问题1. 忘记delete local reference。带New到方法(如:NewByteArray)这样到方法比较好辨认,需要手动调用DeleteLocalRef()来释放(返回值除外)。比较特殊的一个方法是:GetByteArrayELement必须要调用ReleaseByteArrayElements进行释放。当然如果你只是取bytearray中到byte,那么完全可以用GetByteArrayRegion实现。 问题2. 没有NewGlobalRef。 在不同线程调用java方法,需要保存jobject对象,这时需要对jobject对象做全局引用,否则会失效。.. 阅读全文
posted @ 2014-03-03 15:20 porter_代码工作者 阅读(624) 评论(0) 推荐(0) 编辑
摘要:一、概述 JNI编程和Linux上的C/C++编程还是挺相似的,每次java调用JNI中的函数时都会传入有关JVM的一些参数(如JNIEnv,jobject),每次JNI回调java中的方法时都要通过JVM的有关参数来实现,当在JNI中涉及到多线程的话还是有一些不一样的地方,就是要在子线程函数里使用AttachCurrentThread()和DetachCurrentThread()这两个函数,在这两个函数之间加入回调java方法所需要的代码。 #include#include#include#include#include#include#define LOGI(...) ((void... 阅读全文
posted @ 2014-03-03 15:20 porter_代码工作者 阅读(1134) 评论(0) 推荐(0) 编辑
摘要:A JNI interface pointer (JNIEnv*) is passed as an argument for each native function mapped to a Java method, allowing for interaction with the JNI environment within the native method.This JNI interface pointer can be stored, but remains valid only in the current thread.Other threads must first call 阅读全文
posted @ 2014-03-03 14:51 porter_代码工作者 阅读(2274) 评论(0) 推荐(0) 编辑
摘要:// Note://int x = a[0].GetInt(); // Error: operator[ is ambiguous, as 0 also mean a null pointer of const char* type.int y = a[SizeType(0)].GetInt(); // Cast to SizeType will work.int z = a[0u].GetInt(); // This works too.0u = SizeType(0)Json::Value作为数组时,读取0位置时,出现错误:Use of overload... 阅读全文
posted @ 2014-03-03 14:11 porter_代码工作者 阅读(1481) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示