Skip to content

Commit ef1bde9

Browse files
committed
增加 cpp support的readme和示例
1 parent c2fd7b1 commit ef1bde9

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

demo/x86-gcc/makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
all : mkdir out
22

3-
out : main.o shell_port.o shell.o shell_ext.o shell_cmd_list.o shell_companion.o shell_fs.o shell_cmd_group.o
3+
out : main.o shell_port.o shell.o shell_ext.o shell_cmd_list.o shell_companion.o shell_fs.o shell_cmd_group.o shell_cpp.o
44
gcc -o build/out -T shell.lds build/main.o build/shell_port.o \
55
build/shell.o build/shell_ext.o build/shell_cmd_list.o \
6-
build/shell_companion.o build/shell_fs.o build/shell_cmd_group.o
6+
build/shell_companion.o build/shell_fs.o build/shell_cmd_group.o \
7+
build/shell_cpp.o
78

89
main.o : main.c shell_port.h
910
gcc -c main.c -I ./ -I ../../src -o build/main.o
@@ -29,6 +30,9 @@ shell_fs.o : ../../extensions/fs_support/shell_fs.c ../../extensions/fs_support/
2930
shell_cmd_group.o : ../../extensions/shell_enhance/shell_cmd_group.c ../../extensions/shell_enhance/shell_cmd_group.h shell_cfg.h ../../src/shell.h
3031
gcc -c ../../extensions/shell_enhance/shell_cmd_group.c -I ./ -I ../../src -I ../../extensions/shell_enhance -o build/shell_cmd_group.o
3132

33+
shell_cpp.o : shell_cpp.cpp ../../extensions/cpp_support/shell_cpp.h
34+
g++ -c shell_cpp.cpp -I ./ -I ../../src -I ../../extensions/cpp_support -o build/shell_cpp.o
35+
3236
.PHONY : all clean mkdir
3337
clean :
3438
-rm -r build

demo/x86-gcc/shell_cpp.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @file shell_cpp.cpp
3+
* @author Letter
4+
* @brief shell cpp support test
5+
* @version 0.1
6+
* @date 2021-01-17
7+
*
8+
* @copyright (c) 2021 Letter
9+
*
10+
*/
11+
12+
#include <shell_cpp.h>
13+
14+
void cppTest(void)
15+
{
16+
Shell *shell = shellGetCurrent();
17+
shellPrint(shell, "hello world from cpp\r\n");
18+
}
19+
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC),
20+
cppTest, cppTest, cpp test);

extensions/cpp_support/readme.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# cpp suport
2+
3+
![standard](https://img.shields.io/badge/standard-c99-brightgreen.svg)
4+
![build](https://img.shields.io/badge/build-2021.01.17-brightgreen.svg)
5+
![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)
6+
7+
`letter shell`cpp支持
8+
9+
## 简介
10+
11+
`cpp support`是用于扩展`letter shell`,使其可以在cpp环境中生效的组件,`cpp support`仅仅包含一个头文件
12+
13+
## 使用
14+
15+
`cpp support`仅仅提供了一个`shell_cpp.h`的头文件,用于在cpp文件中使用`letter shell`的命令导出,在使用时,需要在`.cpp`文件中包含`shell_cpp.h`,而不是`shell.h`,如果一个工程同时包含`.c``.cpp`文件,只需要分别包含对应的头文件即可
16+
17+
注意,对于cpp,`letter shell`也仅支持函数的导出,不适用于类的成员函数

0 commit comments

Comments
 (0)