关于#pragma push_macro("new") .

本文介绍了一种在C/C++中管理宏定义的技巧,利用预处理指令实现宏定义的临时取消与恢复,避免关键字冲突,并通过示例展示了如何操作。

在三方库源码中,我们经常看到这样的代码:

#pragma push_macro("new")

#undef new

// do something with new

......

#pragma pop_macro("new")

它的作用就是将宏定义new压入栈并取消它(指的是宏)的定义,如此一来,new的本来含义便获得了恢复,使用完毕后将宏定义new弹出栈,恢复宏定义。

不过,仍有下面两个问题需要回答。

1)宏定义名不会与关键字new冲突吗?

2)宏定义new有何作用?

问题1

    宏定义名若与保留的关键字相同,编译器并不会提示错误,而是用最新定义的宏定义代替关键字发挥作用。下面是一个例子,定义了宏int。例程能顺利通过编译链接,其运行结果为8,4,8,与预期相同。

// ConsoleTest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
using namespace std;
#define int double

void _tmain(int argc, _TCHAR* argv[])
{
	int iOne = 1;
	cout<<sizeof(iOne)<<endl;
    #pragma push_macro("int")
    #undef int
	int iTwo = 2;
	cout<<sizeof(iTwo)<<endl;
    #pragma pop_macro("int")

	int iSecond=2;
	cout<<sizeof(iSecond)<<endl;
	system("pause");
}


 

解析:运行结果为8 ,4,8

        宏定义,如#define PI 3.1415926   把程序中出现的PI全部换成3.1415926

        #define int double   该句话表明,把程序中出现int的地方全部替换为double ,(int iOne = 1;cout<<sizeof(iOne)<<endl;相当于iOne为double类型,所以输出8)

 

#pragma push_macro("int")

#undef intint iTwo = 2;

cout<<sizeof(iTwo)<<endl;

#pragma pop_macro("int")

      
上面几句的意思是,将将宏定义int压入栈并取消它(指的是宏)的定义,如此一来,int的本来含义便获得了恢复,即int仍代表int。使用完毕后将宏定义int弹出栈,恢复宏定义即int代表double。

// cstdlib standard header (core) // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #ifndef _CSTDLIB_ #define _CSTDLIB_ #include <yvals_core.h> #if _STL_COMPILER_PREPROCESSOR #include <math.h> #include <stdlib.h> #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new _EXTERN_CXX_WORKAROUND // <stdlib.h> has abs(long) and abs(long long) _NODISCARD _Check_return_ inline double abs(_In_ double _Xx) noexcept /* strengthened */ { return _CSTD fabs(_Xx); } _NODISCARD _Check_return_ inline float abs(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD fabsf(_Xx); } _NODISCARD _Check_return_ inline long double abs(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD fabsl(_Xx); } _END_EXTERN_CXX_WORKAROUND _STD_BEGIN _EXPORT_STD using _CSTD size_t; _EXPORT_STD using _CSTD div_t; _EXPORT_STD using _CSTD ldiv_t; _EXPORT_STD using _CSTD abort; _EXPORT_STD using _CSTD abs; _EXPORT_STD using _CSTD atexit; _EXPORT_STD using _CSTD atof; _EXPORT_STD using _CSTD atoi; _EXPORT_STD using _CSTD atol; _EXPORT_STD using _CSTD bsearch; _EXPORT_STD using _CSTD calloc; _EXPORT_STD using _CSTD div; _EXPORT_STD using _CSTD exit; _EXPORT_STD using _CSTD free; _EXPORT_STD using _CSTD labs; _EXPORT_STD using _CSTD ldiv; _EXPORT_STD using _CSTD malloc; _EXPORT_STD using _CSTD mblen; _EXPORT_STD using _CSTD mbstowcs; _EXPORT_STD using _CSTD mbtowc; _EXPORT_STD using _CSTD qsort; _EXPORT_STD using _CSTD rand; _EXPORT_STD using _CSTD realloc; _EXPORT_STD using _CSTD srand; _EXPORT_STD using _CSTD strtod; _EXPORT_STD using _CSTD strtol; _EXPORT_STD using _CSTD strtoul; _EXPORT_STD using _CSTD wcstombs; _EXPORT_STD using _CSTD wctomb; _EXPORT_STD using _CSTD lldiv_t; _EXPORT_STD using _CSTD getenv; _EXPORT_STD using _CSTD system; _EXPORT_STD using _CSTD atol 代码说是有问题,就是上述两个,给出正确的代码
07-01
ny@wxsc07:~/new/dxp_test_bak - new$ make clean && make CFLAGS="-g" rm -f main.o src/generate_box_pairs.so src/info_partition.so src/output_bin.so src/get_org_info.so src/generate_box_pairs.o src/info_partition.o src/output_bin.o src/get_org_info.o dxp_test mpic++ -I ./include -I /tools/Xilinx/Vitis_HLS/2022.2/include/ -O3 -fPIC -c main.cpp -o main.o In file included from ./include/md_fix.h:5, from main.cpp:7: ./include/ppip_float.h:7: warning: "__always_inline" redefined 7 | #define __always_inline //__attribute__((always_inline)) inline | In file included from /usr/include/features.h:461, from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33, from /usr/include/stdio.h:27, from main.cpp:1: /usr/include/x86_64-linux-gnu/sys/cdefs.h:319: note: this is the location of the previous definition 319 | # define __always_inline __inline __attribute__ ((__always_inline__)) | mpic++ -I ./include -I /tools/Xilinx/Vitis_HLS/2022.2/include/ -O3 -fPIC -c src/generate_box_pairs.cpp -o src/generate_box_pairs.o In file included from ./include/md_fix.h:5, from src/generate_box_pairs.cpp:1: ./include/ppip_float.h:7: warning: "__always_inline" redefined 7 | #define __always_inline //__attribute__((always_inline)) inline | In file included from /usr/include/features.h:461, from /usr/include/x86_64-linux-gnu/c++/9/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/c++config.h:528, from /usr/include/c++/9/bits/stl_algobase.h:59, from /usr/include/c++/9/deque:60, from /usr/include/c++/9/queue:60, from /tools/Xilinx/Vitis_HLS/2022.2/include/hls_stream.h:23, from ./include/md_fix.h:4, from src/generate_box_pairs.cpp:1: /usr/include/x86_64-linux-gnu/sys/cdefs.h:319: note: this is the location of the previous definition 31
03-26
/* uC/CPU CPU CONFIGURATION & PORT LAYER (c) Copyright 2004-2007; Micrium, Inc.; Weston, FL All rights reserved. Protected by international copyright laws. uC/CPU is provided in source form for FREE evaluation, for educational use or peaceful research. If you plan on using uC/CPU in a commercial product you need to contact Micrium to properly license its use in your product. We provide ALL the source code for your convenience and to help you experience uC/CPU. The fact that the source code is provided does NOT mean that you can use it without paying a licensing fee. Knowledge of the source code may NOT be used to develop a similar product. Please help us continue to provide the Embedded community with the finest software available. Your honesty is greatly appreciated. */ /* CPU PORT FILE Freescale MPC55xx Filename : cpu.h Version : V1.17 Programmer(s) : FGK ITJ */ /* MODULE */ #ifndef CPU_CFG_MODULE_PRESENT #define CPU_CFG_MODULE_PRESENT /* CPU INCLUDE FILES Note(s) : (1) The following CPU files are located in the following directories : (a) \<CPU-Compiler Directory>\cpu_def.h (b) \<CPU-Compiler Directory>\<cpu>\<compiler>\cpu*.* where <CPU-Compiler Directory> directory path for common CPU-compiler software <cpu> directory name for specific CPU <compiler> directory name for specific compiler (2) Compiler MUST be configured to include the '\<CPU-Compiler Directory>\' directory & the specific CPU-compiler directory as additional include path directories. */ #include <cpu_def.h> /$PAGE/ /* CONFIGURE STANDARD DATA TYPES Note(s) : (1) Configure standard data types according to CPU-/compiler-specifications. (2) (a) (1) 'CPU_FNCT_VOID' data type defined to replace the commonly-used function pointer data type of a pointer to a function which returns void & has no arguments. (2) Example function pointer usage : CPU_FNCT_VOID FnctName; FnctName(); (b) (1) 'CPU_FNCT_PTR' data type defined to replace the commonly-used function pointer data type of a pointer to a function which returns void & has a single void pointer argument. (2) Example function pointer usage : CPU_FNCT_PTR FnctName; void *pobj FnctName(pobj); */ typedef void CPU_VOID; typedef unsigned char CPU_CHAR; /* 8-bit character / typedef unsigned char CPU_BOOLEAN; / 8-bit boolean or logical / typedef unsigned char CPU_INT08U; / 8-bit unsigned integer / typedef signed char CPU_INT08S; / 8-bit signed integer / typedef unsigned short CPU_INT16U; / 16-bit unsigned integer / typedef signed short CPU_INT16S; / 16-bit signed integer / typedef unsigned long CPU_INT32U; / 32-bit unsigned integer / typedef signed long CPU_INT32S; / 32-bit signed integer / typedef float CPU_FP32; / 32-bit floating point / typedef double CPU_FP64; / 64-bit floating point */ typedef void (CPU_FNCT_VOID)(void); / See Note #2a. */ typedef void (*CPU_FNCT_PTR )(void ); / See Note #2b. */ /$PAGE/ /* CPU WORD CONFIGURATION Note(s) : (1) Configure CPU_CFG_ADDR_SIZE & CPU_CFG_DATA_SIZE with CPU’s word sizes : CPU_WORD_SIZE_08 8-bit word size CPU_WORD_SIZE_16 16-bit word size CPU_WORD_SIZE_32 32-bit word size CPU_WORD_SIZE_64 64-bit word size See Note #1a (a) 64-bit word size NOT currently supported. (2) Configure CPU_CFG_ENDIAN_TYPE with CPU's data-word-memory order : CPU_ENDIAN_TYPE_BIG Big- endian word order (CPU words' most significant octet @ lowest memory address) CPU_ENDIAN_TYPE_LITTLE Little-endian word order (CPU words' least significant octet @ lowest memory address) */ /* Define CPU word sizes (see Note #1) : */ #define CPU_CFG_ADDR_SIZE CPU_WORD_SIZE_32 /* Defines CPU address word size. */ #define CPU_CFG_DATA_SIZE CPU_WORD_SIZE_32 /* Defines CPU data word size. / #define CPU_CFG_ENDIAN_TYPE CPU_ENDIAN_TYPE_BIG / Defines CPU data word-memory order. */ /* CONFIGURE CPU ADDRESS & DATA TYPES */ /* CPU address type based on address bus size. */ #if (CPU_CFG_ADDR_SIZE == CPU_WORD_SIZE_32) typedef CPU_INT32U CPU_ADDR; #elif (CPU_CFG_ADDR_SIZE == CPU_WORD_SIZE_16) typedef CPU_INT16U CPU_ADDR; #else typedef CPU_INT08U CPU_ADDR; #endif /* CPU data type based on data bus size. */ #if (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_32) typedef CPU_INT32U CPU_DATA; #elif (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_16) typedef CPU_INT16U CPU_DATA; #else typedef CPU_INT08U CPU_DATA; #endif typedef CPU_DATA CPU_ALIGN; /* Defines CPU data-word-alignment size. / typedef CPU_DATA CPU_SIZE_T; / Defines CPU standard ‘size_t’ size. */ typedef CPU_INT32U CPU_STK; /* Defines CPU stack size entry. */ /$PAGE/ /* CRITICAL SECTION CONFIGURATION Note(s) : (1) Configure CPU_CFG_CRITICAL_METHOD with CPU’s/compiler’s critical section method : Enter/Exit critical sections by ... CPU_CRITICAL_METHOD_INT_DIS_EN Disable/Enable interrupts CPU_CRITICAL_METHOD_STATUS_STK Push/Pop interrupt status onto stack CPU_CRITICAL_METHOD_STATUS_LOCAL Save/Restore interrupt status to local variable (a) CPU_CRITICAL_METHOD_INT_DIS_EN is NOT a preferred method since it does NOT support multiple levels of interrupts. However, with some CPUs/compilers, this is the only available method. (b) CPU_CRITICAL_METHOD_STATUS_STK is one preferred method since it DOES support multiple levels of interrupts. However, this method assumes that the compiler allows in-line assembly AND will correctly modify the local stack pointer when interrupt status is pushed/popped onto the stack. (c) CPU_CRITICAL_METHOD_STATUS_LOCAL is one preferred method since it DOES support multiple levels of interrupts. However, this method assumes that the compiler provides C-level &/or assembly-level functionality for the following : ENTER CRITICAL SECTION : (a) Save interrupt status into a local variable (b) Disable interrupts EXIT CRITICAL SECTION : (c) Restore interrupt status from a local variable (2) Critical section macro's most likely require inline assembly. If the compiler does NOT allow inline assembly in C source files, critical section macro's MUST call an assembly subroutine defined in a 'cpu_a.asm' file located in the following software directory : \<CPU-Compiler Directory>\<cpu>\<compiler>\ where <CPU-Compiler Directory> directory path for common CPU-compiler software <cpu> directory name for specific CPU <compiler> directory name for specific compiler (3) To save/restore interrupt status, a local variable 'cpu_sr' of type 'CPU_SR' MAY need to be declared (e.g. if 'CPU_CRITICAL_METHOD_STATUS_LOCAL' method is configured). Configure 'CPU_SR' data type with the appropriate-sized CPU data type large enough to completely store the CPU's/compiler's status word. */ typedef volatile CPU_INT32U CPU_SR; /* Defines CPU status register size (see Note #3). */ CPU_SR CPU_SR_Save(void); void CPU_SR_Restore(CPU_SR SR); CPU_SR CPU_SR_Rd(void); /* Configure CPU critical method (see Note #1) : */ #define CPU_CFG_CRITICAL_METHOD CPU_CRITICAL_METHOD_STATUS_LOCAL #define CPU_CRITICAL_ENTER() ( cpu_sr = CPU_SR_Save()) #define CPU_CRITICAL_EXIT() (CPU_SR_Restore(cpu_sr)) #define CPU_IntDis() __asm(“wrteei 0”) #define CPU_IntEn() __asm(“wrteei 1”) /* FUNCTION PROTOTYPES */ /$PAGE/ /* CONFIGURATION ERRORS */ #ifndef CPU_CFG_ADDR_SIZE #error “CPU_CFG_ADDR_SIZE not #define’d in ‘cpu.h’ " #error " [MUST be CPU_WORD_SIZE_08 8-bit alignment]” #error " [ || CPU_WORD_SIZE_16 16-bit alignment]" #error " [ || CPU_WORD_SIZE_32 32-bit alignment]" #elif ((CPU_CFG_ADDR_SIZE != CPU_WORD_SIZE_08) && (CPU_CFG_ADDR_SIZE != CPU_WORD_SIZE_16) && (CPU_CFG_ADDR_SIZE != CPU_WORD_SIZE_32)) #error “CPU_CFG_ADDR_SIZE illegally #define’d in ‘cpu.h’ " #error " [MUST be CPU_WORD_SIZE_08 8-bit alignment]” #error " [ || CPU_WORD_SIZE_16 16-bit alignment]" #error " [ || CPU_WORD_SIZE_32 32-bit alignment]" #endif #ifndef CPU_CFG_DATA_SIZE #error “CPU_CFG_DATA_SIZE not #define’d in ‘cpu.h’ " #error " [MUST be CPU_WORD_SIZE_08 8-bit alignment]” #error " [ || CPU_WORD_SIZE_16 16-bit alignment]" #error " [ || CPU_WORD_SIZE_32 32-bit alignment]" #elif ((CPU_CFG_DATA_SIZE != CPU_WORD_SIZE_08) && (CPU_CFG_DATA_SIZE != CPU_WORD_SIZE_16) && (CPU_CFG_DATA_SIZE != CPU_WORD_SIZE_32)) #error “CPU_CFG_DATA_SIZE illegally #define’d in ‘cpu.h’ " #error " [MUST be CPU_WORD_SIZE_08 8-bit alignment]” #error " [ || CPU_WORD_SIZE_16 16-bit alignment]" #error " [ || CPU_WORD_SIZE_32 32-bit alignment]" #endif #ifndef CPU_CFG_ENDIAN_TYPE #error “CPU_CFG_ENDIAN_TYPE not #define’d in ‘cpu.h’ " #error " [MUST be CPU_ENDIAN_TYPE_BIG ]” #error " [ || CPU_ENDIAN_TYPE_LITTLE]" #elif ((CPU_CFG_ENDIAN_TYPE != CPU_ENDIAN_TYPE_BIG ) && (CPU_CFG_ENDIAN_TYPE != CPU_ENDIAN_TYPE_LITTLE)) #error “CPU_CFG_ENDIAN_TYPE illegally #define’d in ‘cpu.h’ " #error " [MUST be CPU_ENDIAN_TYPE_BIG ]” #error " [ || CPU_ENDIAN_TYPE_LITTLE]" #endif #ifndef CPU_CFG_CRITICAL_METHOD #error “CPU_CFG_CRITICAL_METHOD not #define’d in ‘cpu.h’ " #error " [MUST be CPU_CRITICAL_METHOD_INT_DIS_EN ]” #error " [ || CPU_CRITICAL_METHOD_STATUS_STK ]" #error " [ || CPU_CRITICAL_METHOD_STATUS_LOCAL]" #elif ((CPU_CFG_CRITICAL_METHOD != CPU_CRITICAL_METHOD_INT_DIS_EN ) && (CPU_CFG_CRITICAL_METHOD != CPU_CRITICAL_METHOD_STATUS_STK ) && (CPU_CFG_CRITICAL_METHOD != CPU_CRITICAL_METHOD_STATUS_LOCAL)) #error “CPU_CFG_CRITICAL_METHOD illegally #define’d in ‘cpu.h’ " #error " [MUST be CPU_CRITICAL_METHOD_INT_DIS_EN ]” #error " [ || CPU_CRITICAL_METHOD_STATUS_STK ]" #error " [ || CPU_CRITICAL_METHOD_STATUS_LOCAL]" #endif /* MODULE END */ #endif /* End of CPU cfg module inclusion. */ /* uC/CPU CPU CONFIGURATION & PORT LAYER (c) Copyright 2004-2007; Micrium, Inc.; Weston, FL All rights reserved. Protected by international copyright laws. uC/CPU is provided in source form for FREE evaluation, for educational use or peaceful research. If you plan on using uC/CPU in a commercial product you need to contact Micrium to properly license its use in your product. We provide ALL the source code for your convenience and to help you experience uC/CPU. The fact that the source code is provided does NOT mean that you can use it without paying a licensing fee. Knowledge of the source code may NOT be used to develop a similar product. Please help us continue to provide the Embedded community with the finest software available. Your honesty is greatly appreciated. */ /* CPU CONFIGURATION DEFINES Filename : cpu_def.h Version : V1.17 Programmer(s) : ITJ */ /* CPU WORD CONFIGURATION Note(s) : (1) Configure CPU_CFG_ADDR_SIZE & CPU_CFG_DATA_SIZE in ‘cpu.h’ with CPU’s word sizes : CPU_WORD_SIZE_08 8-bit word size CPU_WORD_SIZE_16 16-bit word size CPU_WORD_SIZE_32 32-bit word size CPU_WORD_SIZE_64 64-bit word size See Note #1a (a) 64-bit word size NOT currently supported. (b) Ideally, CPU_WORD_SIZE #define's would be calculated at compile-time through use of the sizeof() operator. However, some compilers do NOT allow pre-processor directives to include run-time macro's -- e.g. 'sizeof()'. (2) Configure CPU_CFG_ENDIAN_TYPE in 'cpu.h' with CPU's data-word-memory order : CPU_ENDIAN_TYPE_BIG Big- endian word order (CPU words' most significant octet @ lowest memory address) CPU_ENDIAN_TYPE_LITTLE Little-endian word order (CPU words' least significant octet @ lowest memory address) / #ifndef CPU_DEF_H #define CPU_DEF_H / ----------------------- CPU WORD SIZE ---------------------- / #define CPU_WORD_SIZE_08 1 / 8-bit word size = sizeof(CPU_INT08x). / #define CPU_WORD_SIZE_16 2 / 16-bit word size = sizeof(CPU_INT16x). / #define CPU_WORD_SIZE_32 4 / 32-bit word size = sizeof(CPU_INT32x). / #define CPU_WORD_SIZE_64 8 / 64-bit word size = sizeof(CPU_INT64x) [see Note #1a]. */ /* ------------------- CPU WORD-ENDIAN ORDER ------------------ */ #define CPU_ENDIAN_TYPE_NONE 0 /* / #define CPU_ENDIAN_TYPE_BIG 1 / Big- endian word order (CPU words’ most significant … / / … octet @ lowest mem addr). / #define CPU_ENDIAN_TYPE_LITTLE 2 / Little-endian word order (CPU words’ least significant … / / … octet @ lowest mem addr). */ /$PAGE/ /* CRITICAL SECTION CONFIGURATION Note(s) : (1) Configure CPU_CFG_CRITICAL_METHOD with CPU’s/compiler’s critical section method : Enter/Exit critical sections by ... CPU_CRITICAL_METHOD_INT_DIS_EN Disable/Enable interrupts CPU_CRITICAL_METHOD_STATUS_STK Push/Pop interrupt status onto stack CPU_CRITICAL_METHOD_STATUS_LOCAL Save/Restore interrupt status to local variable (a) CPU_CRITICAL_METHOD_INT_DIS_EN is NOT a preferred method since it does NOT support multiple levels of interrupts. However, with some CPUs/compilers, this is the only available method. (b) CPU_CRITICAL_METHOD_STATUS_STK is one preferred method since it DOES support multiple levels of interrupts. However, this method assumes that the compiler allows in-line assembly AND will correctly modify the local stack pointer when interrupt status is pushed/popped onto the stack. (c) CPU_CRITICAL_METHOD_STATUS_LOCAL is one preferred method since it DOES support multiple levels of interrupts. However, this method assumes that the compiler provides C-level &/or assembly-level functionality for the following : ENTER CRITICAL SECTION : (a) Save interrupt status into a local variable (b) Disable interrupts EXIT CRITICAL SECTION : (c) Restore interrupt status from a local variable (2) Critical section macro's most likely require inline assembly. If the compiler does NOT allow inline assembly in C source files, critical section macro's MUST call an assembly subroutine defined in a 'cpu_a.asm' file located in the following software directory : \<CPU-Compiler Directory>\<cpu>\<compiler>\ where <CPU-Compiler Directory> directory path for common CPU-compiler software <cpu> directory name for specific CPU <compiler> directory name for specific compiler (3) To save/restore interrupt status, a local variable 'cpu_sr' of type 'CPU_SR' MAY need to be declared (e.g. if 'CPU_CRITICAL_METHOD_STATUS_LOCAL' method is configured). Configure 'CPU_SR' data type in 'cpu.h' with the appropriate-sized CPU data type large enough to completely store the CPU's/compiler's status word. */ /* --------------- CPU CRITICAL SECTION METHODS --------------- */ #define CPU_CRITICAL_METHOD_NONE 0 /* / #define CPU_CRITICAL_METHOD_INT_DIS_EN 1 / DIS/EN ints. / #define CPU_CRITICAL_METHOD_STATUS_STK 2 / Push/Pop int status onto stk. / #define CPU_CRITICAL_METHOD_STATUS_LOCAL 3 / Save/Restore int status to local var. */ #endif /* INCLUDES */ #include <cpu.h> #ifdef OS_CPU_GLOBALS #define OS_CPU_EXT #else #define OS_CPU_EXT extern #endif /* DATA TYPES */ typedef CPU_BOOLEAN BOOLEAN; typedef CPU_INT08U INT8U; /* Unsigned 8 bit quantity / typedef CPU_INT08S INT8S; / Signed 8 bit quantity / typedef CPU_INT16U INT16U; / Unsigned 16 bit quantity / typedef CPU_INT16S INT16S; / Signed 16 bit quantity / typedef CPU_INT32U INT32U; / Unsigned 32 bit quantity / typedef CPU_INT32S INT32S; / Signed 32 bit quantity / typedef CPU_FP32 FP32; / Single precision floating point / typedef CPU_FP64 FP64; / Double precision floating point */ typedef CPU_STK OS_STK; /* Define size of CPU stack entry / typedef CPU_SR OS_CPU_SR; / Define size of CPU status register */ /* DEFINES */ #define OS_STK_RSVD_SIZE 16 /* EBI Buffer above the stack */ #define OS_STK_GROWTH 1 /* Stack grows from HIGH to LOW memory on PPC */ /* FLOATING POINT Note: also enable or disable “OS_SAVE_CONTEXT_WITH_FPRS .equ 1” in os_cpu_a.h */ #define OS_SAVE_CONTEXT_WITH_FPRS /* OS Task Swicth */ #if defined GNUC #define OS_TASK_SW() asm volatile (" sc “); /#define OSIntCtxSw() asm volatile (" sc ");/ #elif defined MWERKS #define OS_TASK_SW() asm (” sc “); /*#define OSIntCtxSw() asm (” sc “); / #else #define OS_TASK_SW() asm (" sc "); /#define OSIntCtxSw() asm (” sc "); */ #endif /* Critical Method MACROS */ #define OS_CRITICAL_METHOD CPU_CFG_CRITICAL_METHOD #define OS_ENTER_CRITICAL() (cpu_sr = CPU_SR_Save()) #define OS_EXIT_CRITICAL() (CPU_SR_Restore(cpu_sr)) /* Function Prototypes */ void OSCtxSw(void); void OSIntCtxSw(void); void OSStartHighRdy(void); #endif /* OS_CPU_H */ /* uC/OS-II The Real-Time Kernel Freescale MPC55xx Specific code (c) Copyright 2007; Micrium; Weston, FL All Rights Reserved File : OS_CPU_C.C By : Fabiano Kovalski LICENSING TERMS: uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research. If you plan on using uC/OS-II in a commercial product you need to contact Micri to properly license its use in your product. We provide ALL the source code for your convenience and to help you experience uC/OS-II. The fact that the source is provided does NOT mean that you can use it without paying a licensing fee. */ #define OS_CPU_GLOBALS /* INCLUDES */ #include <ucos_ii.h> /* GLOBALS */ extern char SDA_BASE[]; extern char SDA2_BASE[]; /* LOCAL VARIABLES */ #if (OS_VERSION >= 281) && (OS_TMR_EN > 0) static INT16U OSTmrCtr; #endif /* #if(OS_VERSION >= 281) && (OS_TMR_EN > 0) */ /$PAGE/ /* OS INITIALIZATION HOOK (BEGINNING) Description: This function is called by OSInit() at the beginning of OSInit(). Arguments : none Note(s) : 1) Interrupts should be disabled during this call. */ #if(OS_CPU_HOOKS_EN > 0) && (OS_VERSION > 203) void OSInitHookBegin (void) { #if(OS_VERSION >= 281) && (OS_TMR_EN > 0) OSTmrCtr = 0; #endif } #endif /* OS INITIALIZATION HOOK (END) Description: This function is called by OSInit() at the end of OSInit(). Arguments : none Note(s) : 1) Interrupts should be disabled during this call. */ #if(OS_CPU_HOOKS_EN > 0) && (OS_VERSION > 203) void OSInitHookEnd (void) { } #endif /* TASK CREATION HOOK Description: This function is called when a task is created. Arguments : ptcb is a pointer to the task control block of the task being created. Note(s) : 1) Interrupts are disabled during this call. */ #if OS_CPU_HOOKS_EN > 0 void OSTaskCreateHook (OS_TCB ptcb) { #if OS_APP_HOOKS_EN > 0 App_TaskCreateHook(ptcb); #else (void)ptcb; / Prevent compiler warning */ #endif } #endif /$PAGE/ /* TASK DELETION HOOK Description: This function is called when a task is deleted. Arguments : ptcb is a pointer to the task control block of the task being deleted. Note(s) : 1) Interrupts are disabled during this call. */ #if OS_CPU_HOOKS_EN > 0 void OSTaskDelHook (OS_TCB ptcb) { #if OS_APP_HOOKS_EN > 0 App_TaskDelHook(ptcb); #else (void)ptcb; / Prevent compiler warning */ #endif } #endif /* IDLE TASK HOOK Description: This function is called by the idle task. This hook has been added to allow you to do such things as STOP the CPU to conserve power. Arguments : none Note(s) : 1) Interrupts are enabled during this call. */ #if(OS_CPU_HOOKS_EN > 0) && (OS_VERSION >= 251) void OSTaskIdleHook (void) { #if OS_APP_HOOKS_EN > 0 App_TaskIdleHook(); #endif } #endif /* STATISTIC TASK HOOK Description: This function is called every second by uC/OS-II’s statistics task. This allows your application to add functionality to the statistics task. Arguments : none */ #if OS_CPU_HOOKS_EN > 0 void OSTaskStatHook (void) { #if OS_APP_HOOKS_EN > 0 App_TaskStatHook(); #endif } #endif /$PAGE/ /* INITIALIZE A TASK'S STACK Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the stack frame of the task being created. This function is highly processor specific. Arguments : task is a pointer to the task code p_arg is a pointer to a user supplied data area that will be passed to the task when the task first executes. ptos is a pointer to the top of stack. It is assumed that 'ptos' points to a 'free' entry on the task stack. If OS_STK_GROWTH is set to 1 then 'ptos' will contain the HIGHEST valid address of the stack. Similarly, if OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address of the stack. opt specifies options that can be used to alter the behavior of OSTaskStkInit(). (see uCOS_II.H for OS_TASK_OPT_???). Returns : Always returns the location of the new top-of-stack’ once the processor registers have been placed on the stack in the proper order. Note(s) : (1) The SRR1 Register holds the original value of the MSR register. This value is copied to the MSR register by execute the rfi operation at the end of the ISR. (2) Ensure any changes to the order of stack initialization is congruent with the Stack Frame definitions in OS_CPU_A.s. */ OS_STK *OSTaskStkInit (void (*task)(void *pd), void *p_arg, OS_STK *ptos, INT16U opt) { OS_STK stkp; / Local: Stack pointer / OS_CPU_SR msr; / Local: Initial MSR / OS_CPU_SR srr1; / Local: Initial SRR1 */ (void)opt; /* 'opt' is not used, prevent warning */ msr = CPU_SR_Rd(); /* get the MSB reg value */ srr1 = (msr | 0x8000u); /* set MSR[EE] bit to enable interrupts */ stkp = (OS_STK *)((INT32U) ptos & (INT32U) 0xFFFFFFF0u); /* 16-byte align task's stack pointer (EABI) */ /* Leave buffer area for locals "above the stack" in ... */ stkp -= OS_STK_RSVD_SIZE; /* case the compiler prolog puts variables above the stack */ /* Stack Frame Initialization */ #if 0 *--stkp = 0; /* SPEFSCR */ *--stkp = 0; /* USPRG0 */ #endif *--stkp = (INT32U)msr; /* MSR */ *--stkp = 0; /* EABI padding */ *--stkp = 0; /* EABI padding */ *--stkp = (INT32U)task; /* LR */ *--stkp = 0; /* CR */ *--stkp = 0; /* XER */ *--stkp = 0; /* CTR */ *--stkp = (INT32U)srr1; /* SRR1 */ *--stkp = (INT32U)task; /* SRR0 */ *--stkp = 0; /* R0 */ *--stkp = 0x31L; /* r31 */ *--stkp = 0x30L; /* r30 */ *--stkp = 0x29L; /* r29 */ *--stkp = 0x28L; /* r28 */ *--stkp = 0x27L; /* r27 */ *--stkp = 0x26L; /* r26 */ *--stkp = 0x25L; /* r25 */ *--stkp = 0x24L; /* r24 */ *--stkp = 0x23L; /* r23 */ *--stkp = 0x22L; /* r22 */ *--stkp = 0x21L; /* r21 */ *--stkp = 0x20L; /* r20 */ *--stkp = 0x19L; /* r19 */ *--stkp = 0x18L; /* r18 */ *--stkp = 0x17L; /* r17 */ *--stkp = 0x16L; /* r16 */ *--stkp = 0x15L; /* r15 */ *--stkp = 0x14L; /* r14 */ *--stkp = (INT32U)&_SDA_BASE_; /* r13 */ *--stkp = 0x12L; /* r12 */ *--stkp = 0x11L; /* r11 */ *--stkp = 0x10L; /* r10 */ *--stkp = 0x9L; /* r09 */ *--stkp = 0x8L; /* r08 */ *--stkp = 0x7L; /* r07 */ *--stkp = 0x6L; /* r06 */ *--stkp = 0x5L; /* r05 */ *--stkp = 0x4L; /* r04 */ *--stkp = (INT32U)p_arg; /* r03 */ *--stkp = (INT32U)&_SDA2_BASE_; /* r02 */ *--stkp = 0; /* BLANK for 0xA0 size */ *--stkp = (INT32U)ptos; /* Stack Ptr */ return(stkp); } /$PAGE/ /* TASK SWITCH HOOK Description: This function is called when a task switch is performed. This allows you to perform other operations during a context switch. Arguments : none Note(s) : 1) Interrupts are disabled during this call. 2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the task being switched out (i.e. the preempted task). */ #if(OS_CPU_HOOKS_EN > 0) && (OS_TASK_SW_HOOK_EN > 0) void OSTaskSwHook (void) { #if OS_APP_HOOKS_EN > 0 App_TaskSwHook(); #endif } #endif /* OS_TCBInit() HOOK Description: This function is called by OS_TCBInit() after setting up most of the TCB. Arguments : ptcb is a pointer to the TCB of the task being created. Note(s) : 1) Interrupts may or may not be ENABLED during this call. */ #if(OS_CPU_HOOKS_EN > 0) && (OS_VERSION > 203) void OSTCBInitHook (OS_TCB ptcb) { #if OS_APP_HOOKS_EN > 0 App_TCBInitHook(ptcb); #else (void)ptcb; / Prevent compiler warning */ #endif } #endif /* TICK HOOK Description: This function is called every tick. Arguments : none Note(s) : 1) Interrupts may or may not be ENABLED during this call. */ #if(OS_CPU_HOOKS_EN > 0) && (OS_TIME_TICK_HOOK_EN > 0) void OSTimeTickHook (void) { #if OS_APP_HOOKS_EN > 0 App_TimeTickHook(); #endif #if(OS_VERSION >= 281) && (OS_TMR_EN > 0) OSTmrCtr++; if(OSTmrCtr >= (OS_TICKS_PER_SEC / OS_TMR_CFG_TICKS_PER_SEC)) { OSTmrCtr = 0; OSTmrSignal(); } #endif } #endif /* uC/OS-II The Real-Time Kernel DEBUGGER CONSTANTS (c) Copyright 1992-2007, Micrium, Weston, FL All Rights Reserved File : OS_DBG.C By : Jean J. Labrosse Version : V2.86 LICENSING TERMS: uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research. If you plan on using uC/OS-II in a commercial product you need to contact Micri to properly license its use in your product. We provide ALL the source code for your convenience and to help you experience uC/OS-II. The fact that the source is provided does NOT mean that you can use it without paying a licensing fee. */ #include <ucos_ii.h> /* DEBUG DATA */ INT16U const OSDebugEn = OS_DEBUG_EN; /* Debug constants are defined below */ #if OS_DEBUG_EN > 0 INT32U const OSEndiannessTest = 0x12345678L; /* Variable to test CPU endianness */ INT16U const OSEventEn = OS_EVENT_EN; INT16U const OSEventMax = OS_MAX_EVENTS; /* Number of event control blocks / INT16U const OSEventNameSize = OS_EVENT_NAME_SIZE; / Size (in bytes) of event names / #if(OS_EVENT_EN) && (OS_MAX_EVENTS > 0) INT16U const OSEventSize = sizeof(OS_EVENT); / Size in Bytes of OS_EVENT / INT16U const OSEventTblSize = sizeof(OSEventTbl); / Size of OSEventTbl[] in bytes */ #else INT16U const OSEventSize = 0; INT16U const OSEventTblSize = 0; #endif INT16U const OSEventMultiEn = OS_EVENT_MULTI_EN; INT16U const OSFlagEn = OS_FLAG_EN; #if(OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0) INT16U const OSFlagGrpSize = sizeof(OS_FLAG_GRP); /* Size in Bytes of OS_FLAG_GRP / INT16U const OSFlagNodeSize = sizeof(OS_FLAG_NODE); / Size in Bytes of OS_FLAG_NODE / INT16U const OSFlagWidth = sizeof(OS_FLAGS); / Width (in bytes) of OS_FLAGS / #else INT16U const OSFlagGrpSize = 0; INT16U const OSFlagNodeSize = 0; INT16U const OSFlagWidth = 0; #endif INT16U const OSFlagMax = OS_MAX_FLAGS; INT16U const OSFlagNameSize = OS_FLAG_NAME_SIZE; / Size (in bytes) of flag names */ INT16U const OSLowestPrio = OS_LOWEST_PRIO; INT16U const OSMboxEn = OS_MBOX_EN; INT16U const OSMemEn = OS_MEM_EN; INT16U const OSMemMax = OS_MAX_MEM_PART; /* Number of memory partitions / INT16U const OSMemNameSize = OS_MEM_NAME_SIZE; / Size (in bytes) of partition names / #if(OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0) INT16U const OSMemSize = sizeof(OS_MEM); / Mem. Partition header sine (bytes) */ INT16U const OSMemTblSize = sizeof(OSMemTbl); #else INT16U const OSMemSize = 0; INT16U const OSMemTblSize = 0; #endif INT16U const OSMutexEn = OS_MUTEX_EN; INT16U const OSPtrSize = sizeof(void ); / Size in Bytes of a pointer */ INT16U const OSQEn = OS_Q_EN; INT16U const OSQMax = OS_MAX_QS; /* Number of queues / #if(OS_Q_EN > 0) && (OS_MAX_QS > 0) INT16U const OSQSize = sizeof(OS_Q); / Size in bytes of OS_Q structure */ #else INT16U const OSQSize = 0; #endif INT16U const OSRdyTblSize = OS_RDY_TBL_SIZE; /* Number of bytes in the ready table */ INT16U const OSSemEn = OS_SEM_EN; INT16U const OSStkWidth = sizeof(OS_STK); /* Size in Bytes of a stack entry */ INT16U const OSTaskCreateEn = OS_TASK_CREATE_EN; INT16U const OSTaskCreateExtEn = OS_TASK_CREATE_EXT_EN; INT16U const OSTaskDelEn = OS_TASK_DEL_EN; INT16U const OSTaskIdleStkSize = OS_TASK_IDLE_STK_SIZE; INT16U const OSTaskProfileEn = OS_TASK_PROFILE_EN; INT16U const OSTaskMax = OS_MAX_TASKS + OS_N_SYS_TASKS; /* Total max. number of tasks / INT16U const OSTaskNameSize = OS_TASK_NAME_SIZE; / Size (in bytes) of task names */ INT16U const OSTaskStatEn = OS_TASK_STAT_EN; INT16U const OSTaskStatStkSize = OS_TASK_STAT_STK_SIZE; INT16U const OSTaskStatStkChkEn = OS_TASK_STAT_STK_CHK_EN; INT16U const OSTaskSwHookEn = OS_TASK_SW_HOOK_EN; INT16U const OSTCBPrioTblMax = OS_LOWEST_PRIO + 1; /* Number of entries in OSTCBPrioTbl[] / INT16U const OSTCBSize = sizeof(OS_TCB); / Size in Bytes of OS_TCB */ INT16U const OSTicksPerSec = OS_TICKS_PER_SEC; INT16U const OSTimeTickHookEn = OS_TIME_TICK_HOOK_EN; INT16U const OSVersionNbr = OS_VERSION; INT16U const OSTmrEn = OS_TMR_EN; INT16U const OSTmrCfgMax = OS_TMR_CFG_MAX; INT16U const OSTmrCfgNameSize = OS_TMR_CFG_NAME_SIZE; INT16U const OSTmrCfgWheelSize = OS_TMR_CFG_WHEEL_SIZE; INT16U const OSTmrCfgTicksPerSec = OS_TMR_CFG_TICKS_PER_SEC; #if(OS_TMR_EN > 0) && (OS_TMR_CFG_MAX > 0) INT16U const OSTmrSize = sizeof(OS_TMR); INT16U const OSTmrTblSize = sizeof(OSTmrTbl); INT16U const OSTmrWheelSize = sizeof(OS_TMR_WHEEL); INT16U const OSTmrWheelTblSize = sizeof(OSTmrWheelTbl); #else INT16U const OSTmrSize = 0; INT16U const OSTmrTblSize = 0; INT16U const OSTmrWheelSize = 0; INT16U const OSTmrWheelTblSize = 0; #endif #endif /$PAGE/ /* DEBUG DATA TOTAL DATA SPACE (i.e. RAM) USED BY uC/OS-II */ #if OS_DEBUG_EN > 0 INT16U const OSDataSize = sizeof(OSCtxSwCtr) #if(OS_EVENT_EN) && (OS_MAX_EVENTS > 0) + sizeof(OSEventFreeList) + sizeof(OSEventTbl) #endif #if(OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0) + sizeof(OSFlagTbl) + sizeof(OSFlagFreeList) #endif #if OS_TASK_STAT_EN > 0 + sizeof(OSCPUUsage) + sizeof(OSIdleCtrMax) + sizeof(OSIdleCtrRun) + sizeof(OSStatRdy) + sizeof(OSTaskStatStk) #endif #if OS_TICK_STEP_EN > 0 + sizeof(OSTickStepState) #endif #if(OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0) + sizeof(OSMemFreeList) + sizeof(OSMemTbl) #endif #if(OS_Q_EN > 0) && (OS_MAX_QS > 0) + sizeof(OSQFreeList) + sizeof(OSQTbl) #endif #if OS_TIME_GET_SET_EN > 0 + sizeof(OSTime) #endif #if(OS_TMR_EN > 0) && (OS_TMR_CFG_MAX > 0) + sizeof(OSTmrFree) + sizeof(OSTmrUsed) + sizeof(OSTmrTime) + sizeof(OSTmrSem) + sizeof(OSTmrSemSignal) + sizeof(OSTmrTbl) + sizeof(OSTmrFreeList) + sizeof(OSTmrTaskStk) + sizeof(OSTmrWheelTbl) #endif + sizeof(OSIntNesting) + sizeof(OSLockNesting) + sizeof(OSPrioCur) + sizeof(OSPrioHighRdy) + sizeof(OSRdyGrp) + sizeof(OSRdyTbl) + sizeof(OSRunning) + sizeof(OSTaskCtr) + sizeof(OSIdleCtr) + sizeof(OSTaskIdleStk) + sizeof(OSTCBCur) + sizeof(OSTCBFreeList) + sizeof(OSTCBHighRdy) + sizeof(OSTCBList) + sizeof(OSTCBPrioTbl) + sizeof(OSTCBTbl); #endif /$PAGE/ /* OS DEBUG INITIALIZATION Description: This function is used to make sure that debug variables that are unused in the application are not optimized away. This function might not be necessary for all compilers. In this case, you should simply DELETE the code in this function while still leaving the declaration of the function itself. Arguments : none Returns : none Note(s) : (1) This code doesn’t do anything, it simply prevents the compiler from optimizing out the 'const' variables which are declared in this file. (2) You may decide to 'compile out' the code (by using #if 0/#endif) INSIDE the function if your compiler DOES NOT optimize out the 'const' variables above. */ #if OS_DEBUG_EN > 0 void OSDebugInit (void) { void *ptemp; ptemp = (void *)&OSDebugEn; ptemp = (void *)&OSEndiannessTest; ptemp = (void *)&OSEventMax; ptemp = (void *)&OSEventNameSize; ptemp = (void *)&OSEventEn; ptemp = (void *)&OSEventSize; ptemp = (void *)&OSEventTblSize; ptemp = (void *)&OSEventMultiEn; ptemp = (void *)&OSFlagEn; ptemp = (void *)&OSFlagGrpSize; ptemp = (void *)&OSFlagNodeSize; ptemp = (void *)&OSFlagWidth; ptemp = (void *)&OSFlagMax; ptemp = (void *)&OSFlagNameSize; ptemp = (void *)&OSLowestPrio; ptemp = (void *)&OSMboxEn; ptemp = (void *)&OSMemEn; ptemp = (void *)&OSMemMax; ptemp = (void *)&OSMemNameSize; ptemp = (void *)&OSMemSize; ptemp = (void *)&OSMemTblSize; ptemp = (void *)&OSMutexEn; ptemp = (void *)&OSPtrSize; ptemp = (void *)&OSQEn; ptemp = (void *)&OSQMax; ptemp = (void *)&OSQSize; ptemp = (void *)&OSRdyTblSize; ptemp = (void *)&OSSemEn; ptemp = (void *)&OSStkWidth; ptemp = (void *)&OSTaskCreateEn; ptemp = (void *)&OSTaskCreateExtEn; ptemp = (void *)&OSTaskDelEn; ptemp = (void *)&OSTaskIdleStkSize; ptemp = (void *)&OSTaskProfileEn; ptemp = (void *)&OSTaskMax; ptemp = (void *)&OSTaskNameSize; ptemp = (void *)&OSTaskStatEn; ptemp = (void *)&OSTaskStatStkSize; ptemp = (void *)&OSTaskStatStkChkEn; ptemp = (void *)&OSTaskSwHookEn; ptemp = (void *)&OSTCBPrioTblMax; ptemp = (void *)&OSTCBSize; ptemp = (void *)&OSTicksPerSec; ptemp = (void *)&OSTimeTickHookEn; #if OS_TMR_EN > 0 ptemp = (void *)&OSTmrTbl[0]; ptemp = (void *)&OSTmrWheelTbl[0]; ptemp = (void *)&OSTmrEn; ptemp = (void *)&OSTmrCfgMax; ptemp = (void *)&OSTmrCfgNameSize; ptemp = (void *)&OSTmrCfgWheelSize; ptemp = (void *)&OSTmrCfgTicksPerSec; ptemp = (void *)&OSTmrSize; ptemp = (void *)&OSTmrTblSize; ptemp = (void *)&OSTmrWheelSize; ptemp = (void *)&OSTmrWheelTblSize; #endif ptemp = (void *)&OSVersionNbr; ptemp = (void *)&OSDataSize; ptemp = ptemp; /* Prevent compiler warning for 'ptemp' not being used! */ } #endif 将上述代码中的ucosii部分替换为裸机代码
最新发布
12-31
In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:296:39: warning: explicit conversion operators only available with -std=c++11 or -std=gnu++11 [enabled by default] G_EXPLICIT_OP operator bool() const G_NOEXCEPT ^ src/greenlet/greenlet_greenlet.hpp:296:39: error: expected ‘;’ at end of member declaration In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:296:45: note: in expansion of macro ‘G_NOEXCEPT’ G_EXPLICIT_OP operator bool() const G_NOEXCEPT ^ src/greenlet/greenlet_compiler_compat.hpp:79:29: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] Cls(const Cls& other) = delete; \ ^ src/greenlet/greenlet_greenlet.hpp:316:9: note: in expansion of macro ‘G_NO_COPIES_OF_CLS’ G_NO_COPIES_OF_CLS(Greenlet); ^ src/greenlet/greenlet_compiler_compat.hpp:80:40: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] Cls& operator=(const Cls& other) = delete ^ src/greenlet/greenlet_greenlet.hpp:316:9: note: in expansion of macro ‘G_NO_COPIES_OF_CLS’ G_NO_COPIES_OF_CLS(Greenlet); ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:345:39: error: expected ‘;’ at end of member declaration inline intptr_t stack_saved() const G_NOEXCEPT ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:345:45: note: in expansion of macro ‘G_NOEXCEPT’ inline intptr_t stack_saved() const G_NOEXCEPT ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:355:42: error: expected ‘;’ at end of member declaration inline const char* stack_start() const G_NOEXCEPT ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:355:48: note: in expansion of macro ‘G_NOEXCEPT’ inline const char* stack_start() const G_NOEXCEPT ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:389:39: error: expected ‘;’ at end of member declaration inline void slp_restore_state() G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:389:41: note: in expansion of macro ‘G_NOEXCEPT’ inline void slp_restore_state() G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:390:55: error: expected ‘;’ at end of member declaration inline int slp_save_state(char *const stackref) G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:390:57: note: in expansion of macro ‘G_NOEXCEPT’ inline int slp_save_state(char *const stackref) G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:428:45: error: expected ‘;’ at end of member declaration virtual ThreadState* thread_state() const G_NOEXCEPT = 0; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:428:51: note: in expansion of macro ‘G_NOEXCEPT’ virtual ThreadState* thread_state() const G_NOEXCEPT = 0; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:432:51: error: expected ‘;’ at end of member declaration virtual bool was_running_in_dead_thread() const G_NOEXCEPT = 0; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:432:57: note: in expansion of macro ‘G_NOEXCEPT’ virtual bool was_running_in_dead_thread() const G_NOEXCEPT = 0; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:436:41: error: expected ‘;’ at end of member declaration virtual BorrowedGreenlet self() const G_NOEXCEPT = 0; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:436:47: note: in expansion of macro ‘G_NOEXCEPT’ virtual BorrowedGreenlet self() const G_NOEXCEPT = 0; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:490:53: error: expected ‘;’ at end of member declaration virtual OwnedGreenlet g_switchstack_success() G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:490:55: note: in expansion of macro ‘G_NOEXCEPT’ virtual OwnedGreenlet g_switchstack_success() G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:333:63: error: ‘nullptr’ was not declared in this scope const OwnedObject context(const typename IsPy37::IsIt=nullptr) const; ^ src/greenlet/greenlet_greenlet.hpp:336:85: error: ‘nullptr’ was not declared in this scope inline void context(refs::BorrowedObject new_context, typename IsPy37::IsIt=nullptr); ^ src/greenlet/greenlet_greenlet.hpp: In constructor ‘greenlet::Greenlet::switchstack_result_t::switchstack_result_t()’: src/greenlet/greenlet_greenlet.hpp:458:43: error: ‘nullptr’ was not declared in this scope the_state_that_switched(nullptr) ^ src/greenlet/greenlet_greenlet.hpp: In constructor ‘greenlet::Greenlet::switchstack_result_t::switchstack_result_t(int)’: src/greenlet/greenlet_greenlet.hpp:463:43: error: ‘nullptr’ was not declared in this scope the_state_that_switched(nullptr) ^ src/greenlet/greenlet_greenlet.hpp: At global scope: src/greenlet/greenlet_greenlet.hpp:561:51: error: expected ‘;’ at end of member declaration virtual bool was_running_in_dead_thread() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:561:57: note: in expansion of macro ‘G_NOEXCEPT’ virtual bool was_running_in_dead_thread() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:562:45: error: expected ‘;’ at end of member declaration virtual ThreadState* thread_state() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:562:51: note: in expansion of macro ‘G_NOEXCEPT’ virtual ThreadState* thread_state() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:578:41: error: expected ‘;’ at end of member declaration virtual BorrowedGreenlet self() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:578:47: note: in expansion of macro ‘G_NOEXCEPT’ virtual BorrowedGreenlet self() const G_NOEXCEPT; ^ src/greenlet/greenlet_compiler_compat.hpp:79:29: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] Cls(const Cls& other) = delete; \ ^ src/greenlet/greenlet_greenlet.hpp:588:13: note: in expansion of macro ‘G_NO_COPIES_OF_CLS’ G_NO_COPIES_OF_CLS(ParentIsCurrentGuard); ^ src/greenlet/greenlet_compiler_compat.hpp:80:40: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] Cls& operator=(const Cls& other) = delete ^ src/greenlet/greenlet_greenlet.hpp:588:13: note: in expansion of macro ‘G_NO_COPIES_OF_CLS’ G_NO_COPIES_OF_CLS(ParentIsCurrentGuard); ^ src/greenlet/greenlet_compiler_compat.hpp:79:29: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] Cls(const Cls& other) = delete; \ ^ src/greenlet/greenlet_greenlet.hpp:606:9: note: in expansion of macro ‘G_NO_COPIES_OF_CLS’ G_NO_COPIES_OF_CLS(MainGreenlet); ^ src/greenlet/greenlet_compiler_compat.hpp:80:40: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] Cls& operator=(const Cls& other) = delete ^ src/greenlet/greenlet_greenlet.hpp:606:9: note: in expansion of macro ‘G_NO_COPIES_OF_CLS’ G_NO_COPIES_OF_CLS(MainGreenlet); ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:624:51: error: expected ‘;’ at end of member declaration virtual bool was_running_in_dead_thread() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:624:57: note: in expansion of macro ‘G_NOEXCEPT’ virtual bool was_running_in_dead_thread() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:625:45: error: expected ‘;’ at end of member declaration virtual ThreadState* thread_state() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:625:51: note: in expansion of macro ‘G_NOEXCEPT’ virtual ThreadState* thread_state() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:626:39: error: expected ‘;’ at end of member declaration void thread_state(ThreadState*) G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:626:41: note: in expansion of macro ‘G_NOEXCEPT’ void thread_state(ThreadState*) G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:628:41: error: expected ‘;’ at end of member declaration virtual BorrowedGreenlet self() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_internal.hpp:17:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_compiler_compat.hpp:66:20: error: ‘noexcept’ does not name a type #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:628:47: note: in expansion of macro ‘G_NOEXCEPT’ virtual BorrowedGreenlet self() const G_NOEXCEPT; ^ src/greenlet/greenlet_compiler_compat.hpp:66:20: error: expected initializer before ‘noexcept’ #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:694:68: note: in expansion of macro ‘G_NOEXCEPT’ void ExceptionState::operator<<(const PyThreadState *const tstate) G_NOEXCEPT ^ src/greenlet/greenlet_compiler_compat.hpp:66:20: error: expected initializer before ‘noexcept’ #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:703:62: note: in expansion of macro ‘G_NOEXCEPT’ void ExceptionState::operator>>(PyThreadState *const tstate) G_NOEXCEPT ^ src/greenlet/greenlet_compiler_compat.hpp:66:20: error: expected initializer before ‘noexcept’ #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:713:30: note: in expansion of macro ‘G_NOEXCEPT’ void ExceptionState::clear() G_NOEXCEPT ^ src/greenlet/greenlet_compiler_compat.hpp:66:20: error: expected initializer before ‘noexcept’ #define G_NOEXCEPT noexcept ^ src/greenlet/greenlet_greenlet.hpp:722:61: note: in expansion of macro ‘G_NOEXCEPT’ int ExceptionState::tp_traverse(visitproc visit, void* arg) G_NOEXCEPT ^ src/greenlet/greenlet.cpp:187:32: error: expected declaration before end of line # pragma GCC diagnostic push ^ In file included from src/greenlet/greenlet_greenlet.hpp:11:0, from src/greenlet/greenlet_internal.hpp:20, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_refs.hpp:67:9: warning: inline function ‘void greenlet::refs::MainGreenletExactChecker(void*)’ used but never defined [enabled by default] MainGreenletExactChecker(void *p); ^ src/greenlet/greenlet_refs.hpp:181:19: warning: inline function ‘T* greenlet::refs::PyObjectPointer<T, <anonymous> >::borrow() const [with T = _greenlet; void (* TC)(void*) = greenlet::refs::MainGreenletExactChecker]’ used but never defined [enabled by default] inline T* borrow() const G_NOEXCEPT ^ src/greenlet/greenlet_refs.hpp:181:19: warning: inline function ‘T* greenlet::refs::PyObjectPointer<T, <anonymous> >::borrow() const [with T = _object; void (* TC)(void*) = greenlet::refs::NoOpChecker]’ used but never defined [enabled by default] src/greenlet/greenlet_refs.hpp:191:19: warning: inline function ‘T* greenlet::refs::PyObjectPointer<T, <anonymous> >::operator->() const [with T = _object; void (* TC)(void*) = greenlet::refs::NoOpChecker]’ used but never defined [enabled by default] inline T* operator->() const G_NOEXCEPT ^ In file included from src/greenlet/greenlet_internal.hpp:20:0, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_greenlet.hpp:209:21: warning: inline function ‘bool greenlet::StackState::started() const’ used but never defined [enabled by default] inline bool started() const G_NOEXCEPT; ^ src/greenlet/greenlet_greenlet.hpp:211:21: warning: inline function ‘bool greenlet::StackState::active() const’ used but never defined [enabled by default] inline bool active() const G_NOEXCEPT; ^ src/greenlet/greenlet_greenlet.hpp:210:21: warning: inline function ‘bool greenlet::StackState::main() const’ used but never defined [enabled by default] inline bool main() const G_NOEXCEPT; ^ In file included from src/greenlet/greenlet_greenlet.hpp:11:0, from src/greenlet/greenlet_internal.hpp:20, from src/greenlet/greenlet.cpp:19: src/greenlet/greenlet_refs.hpp:181:19: warning: inline function ‘T* greenlet::refs::PyObjectPointer<T, <anonymous> >::borrow() const [with T = _greenlet; void (* TC)(void*) = greenlet::refs::GreenletChecker]’ used but never defined [enabled by default] inline T* borrow() const G_NOEXCEPT ^ error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-30998ynj/greenlet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jfkgxde5-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-30998ynj/greenlet/ 还是报错,Python.h再文件夹中可以看到
07-23
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IvanLJF

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值