Skip to content

Commit

Permalink
增加 cpp support的readme和示例
Browse files Browse the repository at this point in the history
  • Loading branch information
NevermindZZT committed Jan 17, 2021
1 parent c2fd7b1 commit ef1bde9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
8 changes: 6 additions & 2 deletions demo/x86-gcc/makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
20 changes: 20 additions & 0 deletions demo/x86-gcc/shell_cpp.cpp
Original file line number Diff line number Diff line change
@@ -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 <shell_cpp.h>

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);
17 changes: 17 additions & 0 deletions extensions/cpp_support/readme.md
Original file line number Diff line number Diff line change
@@ -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`也仅支持函数的导出,不适用于类的成员函数

0 comments on commit ef1bde9

Please sign in to comment.