I am getting ClassID undeclared error in the following cpp code.
#include "stdafx.h"
#include <iostream>
using namespace std;
#define RM_SESSION_MSG 0x11
#define DECLARE_RS232_MSG(ClassID)
enum
{
ID=ClassID
}
int main()
{
DECLARE_RS232_MSG(RM_SESSION_MSG)
return 0;
}
You are missing the line splice characters
The line splice characters say that the current line and the next line are merged into a single line.
Without them, the macro definition ends at the end-of-line, so the
enumin your code wasn’t really part of the macroDECLARE_RS232_MSG.You also miss a semicolon after the macro invocation in
main(there needs to be a semicolon after each class or enumeration definition in C++).