Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHELL_EXPORT_CMD 编译报error: attribute "section" does not apply to automatic variables #15

Open
panguoxian opened this issue Oct 12, 2019 · 6 comments

Comments

@panguoxian
Copy link

使用 SHELL_EXPORT_CMD 编译报error: attribute "section" does not apply to automatic variables。

其实本人对如何添加命令不是很理解,可否有详细例程说明一下。非常感谢,这是一个很棒的项目。

命令在什么地方实现?如何添加命令?

@NevermindZZT
Copy link
Owner

使用命令导出的方式,命令可以在任意C文件实现,同样可以在任意C文件定义,命令定义就是一个全局变量,只要可以引用到命令实现的函数即可

@NevermindZZT
Copy link
Owner

这个错误是在gcc环境下吗,是不是使用命令导出方式

@panguoxian
Copy link
Author

这个错误是在gcc环境下吗,是不是使用命令导出方式

GCC和MDK环境下都是相同的错误,
MDK报attribute "section" does not apply to automatic variables 跳转到
SHELL_EXPORT_CMD(func, func, test);
GCC报section attribute cannot be specified for local variables 跳转到
shell 命令导出
shellCommand##cmd SECTION("shellCommand") =
{
shellCmd##cmd,
(int (*)())func,
shellDesc##cmd,
(void *)0
}
可能是我理解能力问题,不是很理解命令导出是什么意思,可以解释一下吗?
非常感谢。

@panguoxian
Copy link
Author

这个错误是在gcc环境下吗,是不是使用命令导出方式

已解决,非常感谢。

@byBaldRoad
Copy link

这个错误是在gcc环境下吗,不是使用命令导出方式

已解决,非常感谢。

你好,我在gcc环境下也遇到这个问题 我是c/c++混合编程 请问你是怎么解决的?

@ax11071039
Copy link

我碰到过这个问题,是导出函数内部缺少一个花括号,导致GCC认为的SHELL_EXPORT_CMD的导出函数是一个局部变量。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants