简体   繁体   English

C++ 错误:“<<”标记之前的预期主表达式

[英]C++ error: Expected primary-expression before '<<' token

I have written a very simple C++ code but I don't know why I am getting this error.我写了一个非常简单的 C++ 代码,但我不知道为什么会出现这个错误。 Can anyone help me?谁能帮我?

#include <iostream>
using namespace std;

#define MKSTR( x ) #x
#define concat(a,b) a ## b;
int main () {
    int xy = 100;
    cout << MKSTR(HELLO C++) << endl;
    cout << concat(x,y) << endl;  // I am getting an error here
   return 0;
}
#define concat(a,b) a ## b;
                          ^

Extraneous semi-colon.外来的分号。

define is a pre-processor directive and doesn't require a semi-colon, remove it. define是一个预处理器指令,不需要分号,删除它。

#define concat(a,b) a ## b

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM