
Hi,
the following piece of code:
#include

AMDG On 03/22/2012 01:11 PM, petros wrote:
#include
#include #include #define barfoo (2, (1, 2) ) BOOST_PP_ARRAY_PUSH_BACK( barfoo, 3 )
gived the following compilation error ( MSVC2010, win7 ) :
1>Build started 3/22/2012 4:06:39 PM. 1>ClCompile: 1> opexp.cpp 1>opexp.cpp(6): error C2059: syntax error : 'constant'
Any ideas why this happens ?
The macro is fine. (3, (1, 2, 3)) is not valid C++. In Christ, Steven Watanabe

Thx for the reply. Did not understand it though. And yes, I could not understand the definition myself, but copied from the example of the official documentation: http://www.boost.org/doc/libs/1_48_0/libs/preprocessor/doc/index.html How is this different from the example in there ? Apologies in advance, if I have really missed something obvious. TIA, P- ps: it might help if more examples were avail. the only by the name array really does lists .. -----Original Message----- From: Steven Watanabe Sent: Thursday, March 22, 2012 6:37 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] BOOST_PP_ARRAY_PUSH_BACK AMDG On 03/22/2012 01:11 PM, petros wrote:
#include
#include #include #define barfoo (2, (1, 2) ) BOOST_PP_ARRAY_PUSH_BACK( barfoo, 3 )
gived the following compilation error ( MSVC2010, win7 ) :
1>Build started 3/22/2012 4:06:39 PM. 1>ClCompile: 1> opexp.cpp 1>opexp.cpp(6): error C2059: syntax error : 'constant'
Any ideas why this happens ?
The macro is fine. (3, (1, 2, 3)) is not valid C++. In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

AMDG On 03/22/2012 04:33 PM, petros wrote:
Thx for the reply. Did not understand it though.
Okay, lets walk through it. Start with the macro call: BOOST_PP_ARRAY_PUSH_BACK( barfoo, 3 ) barfoo is a two element array, containing the values 1 and 2. Thus, when we call push back we get a three element array containing 1, 2, and 3. Therefore, the macro expands to (3, (1, 2, 3)) If you run the preprocessor only, you will get an output file containing this. However, you aren't running just the preprocessor. The compiler runs on the output of the preprocessor. You couldn't put (3, (1, 2, 3)) in a C++ source file and expect it to compile. Well, it makes no difference to the compiler whether it's directly in the source, or the result of a macro expansion. It's illegal either way. Hence your error.
And yes, I could not understand the definition myself, but copied from the example of the official documentation: http://www.boost.org/doc/libs/1_48_0/libs/preprocessor/doc/index.html How is this different from the example in there ?
It isn't. That example won't compile either. In Christ, Steven Watanabe

Steven, Thank you very much for the "walk". Makes perfect sense. All the Best, Petros -----Original Message----- From: Steven Watanabe Sent: Friday, March 23, 2012 12:16 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] BOOST_PP_ARRAY_PUSH_BACK AMDG On 03/22/2012 04:33 PM, petros wrote:
Thx for the reply. Did not understand it though.
Okay, lets walk through it. Start with the macro call: BOOST_PP_ARRAY_PUSH_BACK( barfoo, 3 ) barfoo is a two element array, containing the values 1 and 2. Thus, when we call push back we get a three element array containing 1, 2, and 3. Therefore, the macro expands to (3, (1, 2, 3)) If you run the preprocessor only, you will get an output file containing this. However, you aren't running just the preprocessor. The compiler runs on the output of the preprocessor. You couldn't put (3, (1, 2, 3)) in a C++ source file and expect it to compile. Well, it makes no difference to the compiler whether it's directly in the source, or the result of a macro expansion. It's illegal either way. Hence your error.
And yes, I could not understand the definition myself, but copied from the example of the official documentation: http://www.boost.org/doc/libs/1_48_0/libs/preprocessor/doc/index.html How is this different from the example in there ?
It isn't. That example won't compile either. In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
petros
-
Steven Watanabe