Domanda

Ce ne sono, possiamo vedere i risultati in IDE?

Quindi provo il campione di codice che utilizza boost preprocessore e è mostrato qui (! Avvertenza - Russia):

#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;
}

Il mio IDE è VS2010 (Ultimate), mi chiedo come vedere il mio codice come lo vede IDE - Meanig con la mia definizione trasformata in codice. Può essere fatto all'interno dell'IDE, può essere fatto da Vs Consol?

È stato utile?

Soluzione

È possibile eseguire il compilatore Visual Studio dal CommandLine con CL /E per fare l'equivalente di GCC -E (cioè preelaborato). Non sono a conoscenza di un modo per farlo dall'IDE stesso.

Come dice @MooingDuck, è possibile eliminare l'origine preelaborata in un file configurabile che è possibile visualizzare dall'IDE anche se non è possibile ottenere l'output preelaborato su una bobina direttamente su una finestra di output IDE afaik.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top