你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

#pragma once在keil中怎么使用

[复制链接]
wu18946796976 提问时间:2019-8-21 15:25 /
#pragma once可以在keil中使用吗,为什么我用了以后系统提示警告
#pragma once in main file  求解
是不可以用还是需要怎么设置
收藏 评论9 发布时间:2019-8-21 15:25

举报

9个回答
Dandjinh 回答时间:2019-8-22 08:47:24
换成V6编译器应该可以,V6是clang,用的是gcc那一套
STM1024 回答时间:2019-8-21 16:29:23
这个受到编译器特性影响,如果编译器(准确来说应该是预处理器)不支持,就没法使用。
实在不行还是老老实实的#ifndef吧。

评分

参与人数 1蝴蝶豆 +2 收起 理由
STMCU + 2

查看全部评分

TLLED 回答时间:2019-8-21 17:33:14
keil 好像不支持#pragma once关键字
wu18946796976 回答时间:2019-8-22 08:11:50
TLLED 发表于 2019-8-21 17:33
keil 好像不支持#pragma once关键字

多谢  不支持那就没办法了
wu18946796976 回答时间:2019-8-22 08:12:55
stm1024 发表于 2019-8-21 16:29
这个受到编译器特性影响,如果编译器(准确来说应该是预处理器)不支持,就没法使用。
实在不行还是老老实 ...

多谢  不支持就没办法了 。。。。
wu18946796976 回答时间:2019-8-22 09:41:01
Dandjinh 发表于 2019-8-22 08:47
换成V6编译器应该可以,V6是clang,用的是gcc那一套

good  换成V6真可以啊  赞一个  用V6有没有其他问题  先用一段时间看看
butterflyspring 回答时间:2019-8-22 15:42:20
不过很多例程代码都没用到这个,所以按常规的写代码也有好处的
STM1024 回答时间:2019-8-23 11:12:03
wu18946796976 发表于 2019-8-22 08:12
多谢  不支持就没办法了 。。。。

#pragma once

9.90 #pragma once
Enable the compiler to skip subsequent includes of that header file.
#pragma once is accepted for compatibility with other compilers, and enables you to use other forms of header guard coding. However, ARM recommends to use #ifndef and #define coding because this is more portable.
Example
The following example shows the placement of a #ifndef guard around the body of the file, with a #define of the guard variable after the #ifndef.
#ifndef FILE_H
#define FILE_H
#pragma once         // optional
... body of the header file ...
#endif
The #pragma once is marked as optional in this example. This is because the compiler recognizes the #ifndef header guard coding and skips subsequent includes even if #pragma once is absent.
需要翻译吗?哈哈

评分

参与人数 1蝴蝶豆 +2 收起 理由
STMCU + 2

查看全部评分

wu18946796976 回答时间:2019-8-24 10:18:40
stm1024 发表于 2019-8-23 11:12
#pragma once

9.90 #pragma once

太小瞧我了   这点水平还是有的
这是语法功能啊  这个我知道  编译器现在不识别  现在已经解决了  换成V6的编译器就可以了  

所属标签

相似问题

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版