C++ - 为什么使用宏时此代码不起作用?

0 c++ macros

当我a->url在宏中使用它然后它失败了,但是当我替换a->url并手动放入字符串时它可以工作.如何a->url与宏兼容?

g++    -c -g -std=c++11 -MMD -MP -MF "build/Debug/GNU-MacOSX/main.o.d" -o build/Debug/GNU-MacOSX/main.o main.cpp
main.cpp:18:35: error: expected ';' after expression
  cout << MANIFEST_URL(a->url);
Run Code Online (Sandbox Code Playgroud)

码:

#include <iostream>
#include <ctime>
#include <string>
using namespace std;

#define MANIFEST_URL(REPLACE) "https://" REPLACE "/manifest.json";

typedef struct custom {
  char *id;
  string url;  
  custom *next;   
} custom;

int main() {  
  custom *a;
  a = new custom;
  a->url = "www.google.com";  
  cout << MANIFEST_URL(a->url);
  cout << a->url;  
  return 0;  
}
Run Code Online (Sandbox Code Playgroud)

use*_*751 5

你的宏扩展到这个:

cout << "https://" a->url "/manifest.json";;
Run Code Online (Sandbox Code Playgroud)

这显然是无效的.