Question

Is there any, can we see results in IDE?

So I try code sample that uses boost preprocessor and is shown here (!warning - russian):

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

My IDE is VS2010 (ultimate), I wonder how to see my code as IDE sees it - meanig with my define turned into code. Can it be done inside IDE, can it be done from VS consol?

Was it helpful?

Solution

You can run the Visual Studio compiler from the commandline with CL /E to do the equivalent of gcc's -E (i.e. preprocessed). I'm not aware of a way to do this from the IDE itself.

As @MooingDuck says, you can output preprocessed source to a configurable file which you can view from the IDE although you can't get the preprocessed output to spool directly to an IDE output window AFAIK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top