views:

17

answers:

1

From a native, external library, I get a header file with enum declarations:

#define LIST(declare) \
   declare(A, "aaa") \
   declare(B, "bbb") \
   declare(C, "ccc") \

Using it, I create a .NET enum:

#define EXTRACT(p1,p2)  p1,
enum class Val { LIST(EXTRACT) };

Which works great. The result is Val.A, ... values. Now, I would like to auto-generate /// aaa html doc using the same method, so that macro's output would look like this:

enum class Val {
    /// aaa
    A,
    /// bbb
    B,
    /// ccc
    C,
}

Creating a macro like

#define EXTRACT(p1,p2) /// p2 \
                           p1,

does not work because C++ compiler treats /// as a comment, which goes to the next line because of the \ at the end of the line.

Is it possible at all to achive this without using codegen tools? Thanks!

+1  A: 

Microsoft's preprocessor does not preserve comments in macros. So technically inserting a newline is impossible. See this Q&A for details.

So that makes your code generation impossible using MS's preprocessor in the first place.

Vlad Lazarenko