gpt4 book ai didi

c++ - _THROW 未在 GCC 中定义?

转载 作者:行者123 更新时间:2023-11-28 01:06:29 25 4
gpt4 key购买 nike

请告诉我 _THROW 宏在 GCC4 中定义的位置或如何手动定义它

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <climits>
#include <stdexcept>
#include <sys/cdefs.h>
#include <sys/types.h>

void test() { _THROW(std::range_error,"Test"); }

最佳答案

如果要在 C++ 中抛出异常,请使用标准 C++ throw 关键字:

 throw std::range_error("Test"); 

请避免使用某些特定于编译器的内部宏。


如果您必须定义它,那就开始吧:

#define _THROW(e, ...) throw e(__VA_ARGS__)

关于c++ - _THROW 未在 GCC 中定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5818050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com