[SCOPE_EXIT] compiler errors for structure members

struct { int one; } test ; test.one = 55; BOOST_SCOPE_EXIT( ( test.one ) ) { } BOOST_SCOPE_EXIT_END The above code gives me lots of compiler errors. Is there a special syntax I have to provide to be able to use structure members? Thanks, -Sid Sacek The errors I get using MSVC 2008 are: error C2065: 'boost_se_tag_0_12' : undeclared identifier error C2144: syntax error : 'int' should be preceded by ')' error C2059: syntax error : ')' error C2065: 'boost_se_tag_0_12' : undeclared identifier error C2143: syntax error : missing ')' before 'constant' error C2039: 'type' : is not a member of '`global namespace'' error C2653: 'boost_se_wrapped_t_0_12' : is not a class or namespace name error C2143: syntax error : missing ';' before '{' error C2065: 'boost_se_param_t_0_12' : undeclared identifier error C2065: 'boost_se_tag_0_12' : undeclared identifier error C2065: 'boost_se_tag_0_12' : undeclared identifier error C2143: syntax error : missing ',' before 'constant' C2143: syntax error : missing ',' before ')' error C2653: 'boost_se_params_t_12' : is not a class or namespace name error C2143: syntax error : missing ';' before '{' error C2143: syntax error : missing ';' before '}' error C2143: syntax error : missing ';' before '}' error C2143: syntax error : missing ',' before ')'

Sid Sacek <ssacek <at> securewatch24.com> writes:
struct {
int one;
} test ;
test.one = 55;
BOOST_SCOPE_EXIT( ( test.one ) )
{
}
BOOST_SCOPE_EXIT_END
The above code gives me lots of compiler errors. Is there a special syntax I have to provide to be able to use structure members?
This is not supported because only identifiers are allowed. If test was a variable of non-local non-anonymous struct type, you could pass it: BOOST_SCOPE_EXIT( (test ) ) { int one = test.one; ... } BOOST_SCOPE_EXIT_END Alex

struct { int one; } test ; test.one = 55;
BOOST_SCOPE_EXIT( ( test.one ) ) { } BOOST_SCOPE_EXIT_END
The above code gives me lots of compiler errors. Is there a special syntax I have to provide to be able to use structure members?
This is not supported because only identifiers are allowed. If test was a variable of non-local non-anonymous struct type, you could pass it:
BOOST_SCOPE_EXIT( (test ) ) { int one = test.one; ... } BOOST_SCOPE_EXIT_END
Alex
Thank you, Alex. But unfortunately I couldn't use your suggested syntax because the copy-constructor for the structure is being called ( a couple of times. ) Instead, I'm opting for: struct ttt { int one; } test ; test.one = 55; int *one_ref = &test.one; BOOST_SCOPE_EXIT( ( one_ref ) ) { *one_ref = 666; // experimental code } BOOST_SCOPE_EXIT_END; This solves my problem. What really surprised me however was that when I made 'one_ref' an int&, the original test.one variable never got modified. Some other ( I assume temp variable ) was modified. If you're wondering what this is about, I'm trying to create a new macro that uses your macro. Regards, -Sid Sacek _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Sid Sacek <ssacek <at> securewatch24.com> writes:
struct ttt { int one; } test ;
test.one = 55; int *one_ref = &test.one; BOOST_SCOPE_EXIT( ( one_ref ) ) { *one_ref = 666; // experimental code } BOOST_SCOPE_EXIT_END;
This solves my problem. What really surprised me however was that when I made 'one_ref' an int&, the original test.one variable never got modified. Some other ( I assume temp variable ) was modified. If you're wondering what this is about, I'm trying to create a new macro that uses your macro.
Regards, -Sid Sacek
Try passing one_ref by reference: BOOST_SCOPE_EXIT( (&one_ref ) ) // ^ <=========== HERE Alex

Sid Sacek <ssacek <at> securewatch24.com> writes:
Try passing one_ref by reference:
BOOST_SCOPE_EXIT( (&one_ref ) ) // ^ <=========== HERE
Alex
Yep, that did it. Thanks again. -Sid
You might be interested in this as well :) BOOST_SCOPE_EXIT( (&test) ) Alex

You might be interested in this as well :)
BOOST_SCOPE_EXIT( (&test) )
Alex
Yep, that's usable too. From all of your examples, I believe I've figured out how to use the macro correctly now. Thank you very much. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Alexander Nasonov
-
Sid Sacek