Pregunta

¿Hay alguno, podemos ver los resultados en IDE?

Así que pruebo la muestra de código que usa el preprocesador Boost y se muestra aquí (! Advertencia - ruso):

#include <boost/preprocessor.hpp>
#include <iostream>
#include <string>
#include <map>
#include <vector>

#define DEFINE_OUR_STRUCT(name, seq) DEFINE_OUR_STRUCT_I(name, seq)

#define DEFINE_OUR_STRUCT_I(name, seq)                   \
struct name {                                          \
    DEFINE_OUR_STRUCT_ENUM_FIELDS(seq)                   \
    \
    template <typename functor>                          \
    void apply(Functor functor) {                        \
    DEFINE_OUR_STRUCT_ENUM_APPLY_FIELDS(functor, seq)  \
    }                                                    \
};

#define DEFINE_OUR_STRUCT_EXTRACT_TYPE(tuple)   \
    BOOST_PP_TUPLE_ELEM(2, 0, tuple)

#define DEFINE_OUR_STRUCT_EXTRACT_NAME(tuple)   \
    BOOST_PP_TUPLE_ELEM(2, 1, tuple)

#define DEFINE_OUR_STRUCT_ENUM_FIELDS(seq)              \
    BOOST_PP_SEQ_FOR_EACH(                                \
    DEFINE_OUR_STRUCT_ENUM_FIELDS_OP, ~, seq)

#define DEFINE_OUR_STRUCT_ENUM_FIELDS_OP(z, data, el)   \
    DEFINE_OUR_STRUCT_EXTRACT_TYPE(el)                    \
    DEFINE_OUR_STRUCT_EXTRACT_NAME(el);

#define DEFINE_OUR_STRUCT_ENUM_APPLY_FIELDS(ft, seq)    \
    BOOST_PP_SEQ_FOR_EACH(                                \
    DEFINE_OUR_STRUCT_ENUM_APPLY_FIELDS_OP, ft, seq)

#define DEFINE_OUR_STRUCT_ENUM_APPLY_FIELDS_OP(z, ft, el) \
    ft(DEFINE_OUR_STRUCT_EXTRACT_NAME(el));

//this
DEFINE_OUR_STRUCT(first_struct,
    ((int               , id))
    ((std::vector<char> , data))
    )
// shall turn into 
/*
struct first_struct {
    int                   id;
    std::vector<char>     data;

    template <typename Functor>
    void apply(Functor functor) {
        functor(id);
        functor(data);
    }
};
*/
// ...And probably shall not give as many errors as it does...

    int main()
{
    return 0;
}

Mi IDE es VS2010 (Ultimate), me pregunto cómo ver mi código como lo ve IDE - Meanig con mi define convertido en código. ¿Se puede hacer dentro de IDE, se puede hacer desde VS Consol?

¿Fue útil?

Solución

Puede ejecutar el compilador de Visual Studio desde la línea de comandos con CL /E para hacer el equivalente de GCC -E (es decir, preprocesado). No soy consciente de una forma de hacer esto desde el IDE mismo.

Como dice @mooingduck, puede emitir una fuente preprocesada a un archivo configurable que puede ver desde el IDE, aunque no puede obtener la salida preprocesada en el colapso directamente a una ventana de salida IDE AFAIK.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top