继续折腾下 rt-thread pc simulator

今天折腾了下,rt-thread pc simulator 本来想在visual c++ 2010上跑跑看的,折腾来折腾去,就是不行,用的是env工具,scons --target=vs  scons --target=vs2012  ,不折腾了,累,下班

2020-11-30 ,前几天折腾了下  rt-thread pc simulator 没有成功,今天继续折腾下,从github 下载最新的工程包文件,解压工程包,进入到\bsp\simulator 目录下 scons --target=vs2012 生产工程,由于我现在电脑有安装vs2010,就在电脑上生成2012的工程,后面再调整吧!打开visual studio 工程打开工程文件project.vcxproj  直接选择是,确定就可以了,  项目---属性---常规---平台工具集选择V100,按下F7生成解决方案,\bsp\simulator\applications\mnt.c(27): error C2143: 语法错误 : 缺少“;”(在“类型”的前面)  打开文件,发现没有少

extern int dfs_win32_init(void);
extern rt_err_t rt_win_sharedir_init(const char *name);

dfs_win32_init();
rt_win_sharedir_init("wshare");

这是怎么回事呢,没有错误啊,怎么会报错呢?

百度下别人之前C++工程转换也有类似问题,

实质上,纯c要求局部变量定义必须在函数或局部空间的开头,然后才能有其他语句。

纯c确实对变量声明的位置有要求,c++却可以随用随定义的。 说明vs是严格执行了纯C的标准。变量任意定义是C99的标准。这是C89的标准,C99也没有这个限制。问题是微软拒绝支持C99(包括VS2012),一股当年IE6的作风。可以用/tp参数把程序作为C++代码编译,就可以通过了。或者,根本没有这么麻烦,将int b拉到最顶,就没事了。

就是要你完成所有局部变量的定义,你才能写代码。如下代码,就半点问题没有了:

修改mnt.c 代码如下:

/*
* File : mnt.c
* COPYRIGHT (C) 2008 - 2016, RT-Thread Development Team
*
* Change Logs:
* Date Author Notes
* 2017年4月3日 Urey the first version
*/

#include <rtthread.h>
#include <rtdevice.h>

#ifdef RT_USING_DFS
#include <dfs_fs.h>
#if 1
#ifdef RT_USING_DFS_WINSHAREDIR
extern int dfs_win32_init(void);
extern rt_err_t rt_win_sharedir_init(const char *name);
#endif
#endif

int mnt_init(void)
{
dfs_init();

#ifdef RT_USING_DFS_WINSHAREDIR
//extern int dfs_win32_init(void);
//extern rt_err_t rt_win_sharedir_init(const char *name);

dfs_win32_init();
rt_win_sharedir_init("wshare");

if (dfs_mount("wshare", "/", "wdir", 0, 0) == 0)
{
rt_kprintf("File System on root initialized!\n");
}
else
{
rt_kprintf("File System on root initialization failed!\n");
}

if (dfs_mount("sd0", "/sd", "elm", 0, 0) == 0)
{
rt_kprintf("File System on sd initialized!\n");
}
else
{
rt_kprintf("File System on sd initialization failed!\n");
}
#else
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
{
rt_kprintf("File System on sd initialized!\n");
}
else
{
rt_kprintf("File System on sd initialization failed!\n");
}
#endif

return 0;
}

#endif

重新编译通过。

按下F5运行代码。

\ | /
- RT - Thread Operating System
/ | \ 4.0.3 build Nov 30 2020
2006 - 2020 Copyright by rt-thread team
Hello RT-Thread!
File System on root initialized!
File System on sd initialization failed!
msh />

 

模拟器终于搭好了,以后简单的调试,不依赖硬件部分的就可以放在模拟器上验证了。

ok,mark 一下

 

posted @ 2020-11-19 18:20  xiaoyu_lin  阅读(478)  评论(2编辑  收藏  举报