Chinaunix首页 | 论坛 | 博客
  • 博客访问: 624144
  • 博文数量: 116
  • 博客积分: 6078
  • 博客等级: 准将
  • 技术积分: 1214
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-23 10:09
文章分类

全部博文(116)

文章存档

2016年(1)

2015年(4)

2011年(2)

2010年(21)

2009年(88)

分类: C/C++

2009-05-29 18:13:52

/********************此文可以被转发,但请转发者保留作者的署名权
****李浩
****msn:lihao_nx@hotmail.com
****
****email:lihaoyxj@gmail.com
****出处:lihaoyxj.cublog.cn

*****************/
开始学SYMBIAN起,总是会从symbian c++ 开始,它完全从GUI的一系列对象开始,让人感觉是一个很纯粹的新东西,另外如果真的做一些现有的算法库等的移植时,感觉上很累,因为要改的地方太多太多了。比如memset,而在symbian要用IMPORT_C TAny *memset(TAny *aTrg, TInt aValue, unsigned int aLength);
char,在symbian中用TBuf8或HBufC8等,不论是内存、字符串、运算符等,变化实在太大,让人如果进行移植,实在怕怕。
那么有没有好的办法让人可以直接用标准的C或C++呢?
有,可以用OPENC,如我的S60 3rd FP1
1.下载
2. 安装open c套件。
3. 在carbide中新建一个symbian os的open c console application.
4. 编译并运行。由于命令行下,在SYMBIAN不能直接看到,可按我写的上一篇把模拟器调成文本模式。

可以看到,我按
#include
#include
#include

// This is a GCCE toolchain workaround needed when compiling with GCCE
// and using main() entry point
#ifdef __GCCE__
#include
#endif

int main(void)
    {
    printf("Hello Open C!\n");
    printf("Press a character to exit!\n");
    char* buff;
    buff=(char*)malloc(255);
    memset(buff,0,255);
    strcpy(buff,"Hello,buff\n");
    printf("%s",buff);
    free(buff);
    int c = getchar();
    return 0;
    }
这样的代码执行是完全可行的。但是要注意一点,它在GCCE中需要#include 头文件。
再打开它的MMP文件,看有什么不一样呢
一般的SYMBIAN的MMP
LIBRARY           euser.lib
LIBRARY           apparc.lib
LIBRARY           cone.lib
LIBRARY           eikcore.lib
LIBRARY           avkon.lib
LIBRARY           commonengine.lib
LIBRARY           efsrv.lib
LIBRARY           estor.lib
LIBRARY        aknnotify.lib
LIBRARY        hlplch.lib
open C的mmp
SYSTEMINCLUDE   \epoc32\include\stdapis
// Using main() as entry point
STATICLIBRARY   libcrt0.lib

// libc and euser are always needed when using main() entry point
LIBRARY         libc.lib
LIBRARY         euser.lib
看到了吗?open c 是由libcrt0.lib提供main入口,而一般的为apparc.lib提供NewApplication()这个入口

阅读(1754) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~