汇编错误,非初始化的值' __ PURE'

发布于 2025-02-07 07:12:59 字数 1663 浏览 1 评论 0原文

我正在尝试使用新版本的NORM-NON-AEBI编译器(10.3)编译代码,并且有错误。编译器指向其字符串file.h并给出以下错误,

error: expected initializer before '__pure'
error: expected initializer before '__pure2'

这是什么意思,为什么他不知道呢?我必须自己定义它们吗?

字符串中写有类似的东西。

#include <sys/cdefs.h>
#include <sys/_types.h>

#if __POSIX_VISIBLE >= 200809
#include <sys/_locale.h>
#endif

#ifndef _SIZE_T_DECLARED
typedef __size_t    size_t;
#define _SIZE_T_DECLARED
#endif

__BEGIN_DECLS
#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
int  bcmp(const void *, const void *, size_t) __pure;   /* LEGACY */
void     bcopy(const void *, void *, size_t);           /* LEGACY */
void     bzero(void *, size_t);                 /* LEGACY */
#endif
#if __BSD_VISIBLE
void     explicit_bzero(void *, size_t);
#endif
#if __MISC_VISIBLE || __POSIX_VISIBLE < 200809 || __XSI_VISIBLE >= 700
int  ffs(int) __pure2;
#endif
#if __BSD_VISIBLE
int  ffsl(long) __pure2;
int  ffsll(long long) __pure2;
int  fls(int) __pure2;
int  flsl(long) __pure2;
int  flsll(long long) __pure2;
#endif
#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
char    *index(const char *, int) __pure;           /* LEGACY */
char    *rindex(const char *, int) __pure;          /* LEGACY */
#endif
int  strcasecmp(const char *, const char *) __pure;
int  strncasecmp(const char *, const char *, size_t) __pure;

#if __POSIX_VISIBLE >= 200809
int  strcasecmp_l (const char *, const char *, locale_t);
int  strncasecmp_l (const char *, const char *, size_t, locale_t);
#endif
__END_DECLS

#if __SSP_FORTIFY_LEVEL > 0
#include <ssp/strings.h>
#endif

#endif /* _STRINGS_H_ */

I am trying to compile my code using the new version of the arm-none-eabi compiler (10.3) and I am having errors. The compiler points to its strings file.h and gives the following errors

error: expected initializer before '__pure'
error: expected initializer before '__pure2'

What does this mean and why doesn't he know it? Do I have to define them myself?

Something similar is written inside the strings.h file

#include <sys/cdefs.h>
#include <sys/_types.h>

#if __POSIX_VISIBLE >= 200809
#include <sys/_locale.h>
#endif

#ifndef _SIZE_T_DECLARED
typedef __size_t    size_t;
#define _SIZE_T_DECLARED
#endif

__BEGIN_DECLS
#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
int  bcmp(const void *, const void *, size_t) __pure;   /* LEGACY */
void     bcopy(const void *, void *, size_t);           /* LEGACY */
void     bzero(void *, size_t);                 /* LEGACY */
#endif
#if __BSD_VISIBLE
void     explicit_bzero(void *, size_t);
#endif
#if __MISC_VISIBLE || __POSIX_VISIBLE < 200809 || __XSI_VISIBLE >= 700
int  ffs(int) __pure2;
#endif
#if __BSD_VISIBLE
int  ffsl(long) __pure2;
int  ffsll(long long) __pure2;
int  fls(int) __pure2;
int  flsl(long) __pure2;
int  flsll(long long) __pure2;
#endif
#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
char    *index(const char *, int) __pure;           /* LEGACY */
char    *rindex(const char *, int) __pure;          /* LEGACY */
#endif
int  strcasecmp(const char *, const char *) __pure;
int  strncasecmp(const char *, const char *, size_t) __pure;

#if __POSIX_VISIBLE >= 200809
int  strcasecmp_l (const char *, const char *, locale_t);
int  strncasecmp_l (const char *, const char *, size_t, locale_t);
#endif
__END_DECLS

#if __SSP_FORTIFY_LEVEL > 0
#include <ssp/strings.h>
#endif

#endif /* _STRINGS_H_ */

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溇涏 2025-02-14 07:12:59

您错过了__ pure的定义。

我猜这与__属性有关__((pure))定义pure函数。

作为解决方法,我建议

#define __pure 

它仅影响可能的优化。

纯函数:

呼吁对对未观察到的函数的影响
除了归还价值以外的程序可能会借给自己
优化,例如常见的亚表达消除。宣布这样的
具有纯属属性的功能允许GCC避免发射一些
通过相同参数重复调用该函数的调用
值。

纯属性禁止函数修改状态
除了检查该程序外,该程序可观察到
函数的返回值。但是,用纯的功能声明
属性可以安全地读取任何非易失性对象,并修改
对象的价值,以不影响其退货价值或
该程序的可观察状态。

例如,

  int hash(char *)__attribute__(((pure));
 

告诉GCC随后呼叫与同一函数哈希
可以用第一个呼叫的结果代替字符串
哈希可观察到的程序的状态,包括
阵列本身,不会在两者之间发生变化。即使哈希(Hash)
非符合指针参数,它不得修改指向的数组,
或任何其他程序可能取决于其价值的对象。
但是,呼叫者可以安全更改数组的内容
在连续呼叫该功能之间(这样做可以禁用
优化)。限制也适用于成员对象
该指针在C ++非静态成员函数中引用。

纯函数的一些常见示例是strlen或memcmp。
有趣的非饰面功能是无限循环或
那些取决于挥发性内存或其他系统资源,可能
连续呼叫之间的更改(例如标准C FEOF函数
在多线程环境中)。

纯属属性施加了相似但较大的限制
函数的定义比const属性:pure允许
读取任何非易失性内存的功能,即使它在
在功能的连续调用之间。宣布相同
诊断出具有纯净和常量性属性的功能。
因为纯函数不能具有任何可观察到的副作用
对于这种函数返回空隙是没有意义的。宣布这样的
诊断功能。

You miss definition of __pure.

I guess that is related to __attribute__((pure)) which defines a pure function.

As a workaround, I would suggest

#define __pure 

as it only affects possible optimisations.

Pure function:

Calls to functions that have no observable effects on the state of the
program other than to return a value may lend themselves to
optimizations such as common subexpression elimination. Declaring such
functions with the pure attribute allows GCC to avoid emitting some
calls in repeated invocations of the function with the same argument
values.

The pure attribute prohibits a function from modifying the state of
the program that is observable by means other than inspecting the
function’s return value. However, functions declared with the pure
attribute can safely read any non-volatile objects, and modify the
value of objects in a way that does not affect their return value or
the observable state of the program.

For example,

int hash (char *) __attribute__ ((pure));

tells GCC that subsequent calls to the function hash with the same
string can be replaced by the result of the first call provided the
state of the program observable by hash, including the contents of the
array itself, does not change in between. Even though hash takes a
non-const pointer argument it must not modify the array it points to,
or any other object whose value the rest of the program may depend on.
However, the caller may safely change the contents of the array
between successive calls to the function (doing so disables the
optimization). The restriction also applies to member objects
referenced by the this pointer in C++ non-static member functions.

Some common examples of pure functions are strlen or memcmp.
Interesting non-pure functions are functions with infinite loops or
those depending on volatile memory or other system resource, that may
change between consecutive calls (such as the standard C feof function
in a multithreading environment).

The pure attribute imposes similar but looser restrictions on a
function’s definition than the const attribute: pure allows the
function to read any non-volatile memory, even if it changes in
between successive invocations of the function. Declaring the same
function with both the pure and the const attribute is diagnosed.
Because a pure function cannot have any observable side effects it
does not make sense for such a function to return void. Declaring such
a function is diagnosed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文