_THROW在GCC中没有定义

_THROW not defined in GCC?

本文关键字:定义 GCC THROW      更新时间:2023-10-16

请告诉我_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__)