diff --git a/demo/x86-gcc/makefile b/demo/x86-gcc/makefile index ef6ea6b..3ddd046 100644 --- a/demo/x86-gcc/makefile +++ b/demo/x86-gcc/makefile @@ -1,9 +1,10 @@ all : mkdir out -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 +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 gcc -o build/out -T shell.lds build/main.o build/shell_port.o \ build/shell.o build/shell_ext.o build/shell_cmd_list.o \ - build/shell_companion.o build/shell_fs.o build/shell_cmd_group.o + build/shell_companion.o build/shell_fs.o build/shell_cmd_group.o \ + build/shell_cpp.o main.o : main.c shell_port.h 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/ shell_cmd_group.o : ../../extensions/shell_enhance/shell_cmd_group.c ../../extensions/shell_enhance/shell_cmd_group.h shell_cfg.h ../../src/shell.h gcc -c ../../extensions/shell_enhance/shell_cmd_group.c -I ./ -I ../../src -I ../../extensions/shell_enhance -o build/shell_cmd_group.o +shell_cpp.o : shell_cpp.cpp ../../extensions/cpp_support/shell_cpp.h + g++ -c shell_cpp.cpp -I ./ -I ../../src -I ../../extensions/cpp_support -o build/shell_cpp.o + .PHONY : all clean mkdir clean : -rm -r build diff --git a/demo/x86-gcc/shell_cpp.cpp b/demo/x86-gcc/shell_cpp.cpp new file mode 100644 index 0000000..2c44057 --- /dev/null +++ b/demo/x86-gcc/shell_cpp.cpp @@ -0,0 +1,20 @@ +/** + * @file shell_cpp.cpp + * @author Letter + * @brief shell cpp support test + * @version 0.1 + * @date 2021-01-17 + * + * @copyright (c) 2021 Letter + * + */ + +#include + +void cppTest(void) +{ + Shell *shell = shellGetCurrent(); + shellPrint(shell, "hello world from cpp\r\n"); +} +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), +cppTest, cppTest, cpp test); diff --git a/extensions/cpp_support/readme.md b/extensions/cpp_support/readme.md new file mode 100644 index 0000000..f424153 --- /dev/null +++ b/extensions/cpp_support/readme.md @@ -0,0 +1,17 @@ +# cpp suport + +![standard](https://img.shields.io/badge/standard-c99-brightgreen.svg) +![build](https://img.shields.io/badge/build-2021.01.17-brightgreen.svg) +![license](https://img.shields.io/badge/license-MIT-brightgreen.svg) + +`letter shell`cpp支持 + +## 简介 + +`cpp support`是用于扩展`letter shell`,使其可以在cpp环境中生效的组件,`cpp support`仅仅包含一个头文件 + +## 使用 + +`cpp support`仅仅提供了一个`shell_cpp.h`的头文件,用于在cpp文件中使用`letter shell`的命令导出,在使用时,需要在`.cpp`文件中包含`shell_cpp.h`,而不是`shell.h`,如果一个工程同时包含`.c`和`.cpp`文件,只需要分别包含对应的头文件即可 + +注意,对于cpp,`letter shell`也仅支持函数的导出,不适用于类的成员函数