main.c: error: #13: expected a file name #include CMSIS_device_header main.c: 0 warnings, 1 error
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了main.c: error: #13: expected a file name #include CMSIS_device_header main.c: 0 warnings, 1 error相关的知识,希望对你有一定的参考价值。
KEIL5 编译提示mian函数第6行就是 #include CMSIS_device_header这个以上说缺少文件名expected a file name ,小白求解,用的是KEIL5 自带的mian未修改
根据出错信息,main.c,第6行的:#include CMSIS_device_header
“CMSIS_device_header”不是文件名。从实际情况看,CMSIS_device_header应该是个宏,定义成一个头文件。类似于:
#define CMSIS_device_header “my_header.h”
由于在改行之前有个头文件的引用:
#include "RTE_Components.h"
该宏,很可能在其中定义,但是发生了拼写错误,或者引用条件不对。
如果不是这种情况,则可能是下述之一:
1. 少了一个定义该宏的头文件。
2. 得自己定义。
如有问题继续交流,谢谢。 参考技术A 我使用的是stm32f205的芯片,所以将CMSIS_device_header替换为stm32f2xx.h就好了。
bcc slabratetop fatal error
tools/slabratetop: call to undeclared function ‘slab_address’
When my system uses SLUB And the kernel version >=5.16, there are the following problems:
$ sudo ./slabratetop.py
In file included from /virtual/main.c:13:
include/linux/slub_def.h:162:26: warning: call to undeclared function 'slab_address'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
void *object = x - (x - slab_address(slab)) % cache->size;
^
include/linux/slub_def.h:162:46: error: invalid operands to binary expression ('void *' and 'unsigned int')
void *object = x - (x - slab_address(slab)) % cache->size;
~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
include/linux/slub_def.h:164:8: error: incomplete definition of type 'struct slab'
(slab->objects - 1) * cache->size;
~~~~^
include/linux/kasan.h:13:8: note: forward declaration of 'struct slab'
struct slab;
^
In file included from /virtual/main.c:13:
include/linux/slub_def.h:184:31: warning: call to undeclared function 'slab_address'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
return __obj_to_index(cache, slab_address(slab), obj);
^
include/linux/slub_def.h:184:31: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'void *' [-Wint-conversion]
return __obj_to_index(cache, slab_address(slab), obj);
^~~~~~~~~~~~~~~~~~
include/linux/slub_def.h:173:14: note: passing argument to parameter 'addr' here
void *addr, void *obj)
^
include/linux/slub_def.h:190:13: error: incomplete definition of type 'struct slab'
return slab->objects;
~~~~^
include/linux/kasan.h:13:8: note: forward declaration of 'struct slab'
struct slab;
^
2 warnings and 4 errors generated.
Traceback (most recent call last):
File "/home/rongtao/Git/bcc/tools/./slabratetop.py", line 111, in <module>
b = BPF(text=bpf_text)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/bcc/__init__.py", line 475, in __init__
raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>
see commit 40f3bf0cb04c(“mm: Convert struct page to struct slab in functions used by other subsystems”)
This issue should be modified in the kernel, I’m trying to fix this
https://lore.kernel.org/all/tencent_ABA832E296819D1053D6C625ADCAF76BC706@qq.com/
#if 0
static inline void *nearest_obj(struct kmem_cache *cache, const struct slab *slab,
void *x)
void *object = x - (x - slab_address(slab)) % cache->size;
void *last_object = slab_address(slab) +
(slab->objects - 1) * cache->size;
void *result = (unlikely(object > last_object)) ? last_object : object;
result = fixup_red_left(cache, result);
return result;
#endif
/* Determine object index from a given position */
static inline unsigned int __obj_to_index(const struct kmem_cache *cache,
void *addr, void *obj)
return reciprocal_divide(kasan_reset_tag(obj) - addr,
cache->reciprocal_size);
#if 0
static inline unsigned int obj_to_index(const struct kmem_cache *cache,
const struct slab *slab, void *obj)
if (is_kfence_address(obj))
return 0;
return __obj_to_index(cache, slab_address(slab), obj);
#endif
#if 0
static inline int objs_per_slab(const struct kmem_cache *cache,
const struct slab *slab)
return slab->objects;
#endif
提交 commit
mm: Functions used internally should not be put into slub_def.h
commit 40f3bf0cb04c("mm: Convert struct page to struct slab in functions
used by other subsystems") introduce 'slab_address()' and 'struct slab'
in slab_def.h(CONFIG_SLAB) and slub_def.h(CONFIG_SLUB). When referencing
a header file <linux/slub_def.h> in a module or BPF code, 'slab_address()'
and 'struct slab' are not recognized, resulting in incomplete and
undefined errors(see bcc slabratetop.py error [0]).
Moving the function definitions of reference data structures such as
struct slab and slab_address() such as nearest_obj(), obj_to_index(),
and objs_per_slab() to the internal header file slab.h solves this
fatal problem.
[0] https://github.com/iovisor/bcc/issues/4438
以上是关于main.c: error: #13: expected a file name #include CMSIS_device_header main.c: 0 warnings, 1 error的主要内容,如果未能解决你的问题,请参考以下文章
keil中一直提示错误:main.c(63): error C202: 'num': undefined identifier
Error: Expected resource of type raw [ResourceType]
linux shell 脚本 和 tcn expec 混合的问题
Error while executing: am start -n "" -a android.intent.action.MAIN -c android.intent.cate