1

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?

1 Answer 1

2

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.

3
  • 1
    In the project properties, there's two options, "preprocess to a file" and "name of preprocessed file" You have to open the file seperate once its made though Dec 3, 2011 at 17:32
  • Well... I found /P which can be used inside of the project, which works but for presented demo generates 1600 kb .i file in /obj folder e with so many blanks... and VS does not provide hightlightning for it...(
    – myWallJSON
    Dec 3, 2011 at 17:44
  • @myWallJSON: Well the preprocessed output isn't designed to be readable; it's just an intermediate step for the next stage of the compile.
    – CB Bailey
    Dec 3, 2011 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.