尝试如下嵌套宏调用:
#include <stdint.h>
#define INT
#define LONG
#define AS(t) AS_##t
#define AS_INT as_int
#define AS_LONG as_long
#define LET(v, t) v. AS(t)
typedef union
{
int32_t as_int;
int64_t as_long;
} mytype_t;
int main()
{
mytype_t s;
s.AS(INT) = 10; /* This is OK */
LET(s, INT) = 10; /* This makes error */
return 0;
}
出现错误:
main.c:xx:yy: error: ‘mytype_t {aka union <anonymous>}’ has no member named ‘AS_’
#define LET(v, t) v. AS(t)
^
main.c:zz:ww: note: in expansion of macro ‘LET’
LET(s, INT) = 10;
^~~
是否有任何变通办法可以使用LET(s, INT) = 10;
?
答案 0 :(得分:5)
这是这两个 empty 宏
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use frontend\assets\AppAsset;
use yii\helpers\Html;
AppAsset::register($this);
?>
<?php $this->beginPage()?>
<!DOCTYPE html>
<html lang="<?php echo Yii::$app->language ?>">
<head>
<meta charset="<?php echo Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php echo Html::csrfMetaTags() ?>
<meta name="google-site-verification" content="_LfxXaxrGXxez14d8E2Q8RpIqtoWC7-ZXEW_ylyxsqU" />
<link rel="icon" type="image/png" href="<?php echo Yii::$app->getUrlManager()->createUrl('images/favicon.png'); ?>" />
<?php $this->head()?>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<link href="<?php echo Yii::$app->getUrlManager()->createUrl('css/owl.carousel.min.css'); ?>" rel="stylesheet">
<link href="<?php echo Yii::$app->getUrlManager()->createUrl('css/owl.theme.default.min.css'); ?>" rel="stylesheet" type="text/css">
<link href="<?php echo Yii::$app->getUrlManager()->createUrl('css/fonts.css'); ?>" rel="stylesheet" type="text/css">
<link href="<?php echo Yii::$app->getUrlManager()->createUrl('css/style.css'); ?>" rel="stylesheet" type="text/css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.1/jquery.validate.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCB0tU77lobH0Aq7RZXpOM__TvXaTSmqso&libraries=places"></script>
</head>
<body>
<?php $this->beginBody()?>
<!--START HEADER-->
<?php echo $this->render('@frontend/views/layouts/header.php'); ?>
<!--END HEADER--->
<!--VIEW BODY-->
<?php echo $content; ?>
<!--END BODY-->
<!--START FOOTER-->
<?php echo $this->render('@frontend/views/layouts/footer.php'); ?>
<!--END FOOTER-->
<?php $this->endBody()?>
</body>
</html>
<?php $this->endPage()?>
#define INT
#define LONG
通过INT
传递到AS(t)
时经历中间扩展,并在扩展LET
之前扩展为空令牌序列。这样,您将AS()
与空令牌序列连接在一起。只需删除这两个宏,为您的示例定义AS_
和AS_INT
就足够了。
答案 1 :(得分:1)
已经回答该错误是由于空宏造成的。
另一个解决方案可以是:
#define INT INT
#define LONG LONG
希望这会有所帮助。