In other words, how can I redefine a macro based on it's previous definition? Specifically, I want to add a string to the end of a string macro in C++. This is what I've tried so far:
#define FOO "bla"
// code here will read FOO as "bla"
#define FOO FOO ## "dder"
// code here will read FOO as "bladder"
In C++, this returns error: FOO was not declared in this scope
. How would I do this without getting this error?
EDIT: I've read the comments and found out what an "XY problem" is. What I want to do is make a library for C but the library is written in C++. Because the library requires Classes to function (because it uses other C++ libraries), I wanted to make an empty class that the C program using the library can add custom properties to using Macro functions. Something like this:
// lib.h
#define PROPERTIES ""
#define NEW_PROPERTY(X) // add X + ";\n" to PROPERTIES (somehow)
#ifdef __cplusplus
Class myclass
{
public:
PROPERTIES
}
#endif
_
// c code
#include <lib.h>
NEW_PROPERTY(int id);
NEW_PROPERTY(int color);
int main(){
...
The c program won't need to access the properties because they only exist so that a third-party library that is a dependency for my library can use them.