[Libpqxx-general] Build of tests fail with Sun Studio due to nested template parsing confusion
Bjorn Munch
Bjorn.Munch at sun.com
Wed Aug 20 08:46:12 UTC 2008
Our nightly build of libpqxx with tests on Solaris has failed
lately. The Sun Studio compiler complains when trying to compile
test/test016.cxx:
"test016.cxx", line 55: Error: Illegal value for template parameter.
"test016.cxx", line 55: Error: "," expected instead of ";".
"test016.cxx", line 55: Error: Illegal value for template parameter.
"test016.cxx", line 55: Warning: declarator required in declaration.
The offending line is
PQXX_REGISTER_TEST_T(test_016, robusttransaction<>)
The macro is defined thus:
#define PQXX_REGISTER_TEST_CT(function, connection_type, transaction_type) \
namespace \
{ \
pqxx::test::test_case<connection_type, transaction_type> \
test(#function, function); \
}
When the macro is expanded with the second argument using a template,
it results in an expression with ">>", which apparently confuses the
parser as it sees the >> operator.
It took me some head-scratching to find out what the cause was, but
the solution is simple: add a space before the closing > in the macro
body, to prevent the apparence of >> with nested templates.
After my first patch failed due to tab/space confusion, I have now
applied the following patch and the tests now runs fine. As expected
this also works with gcc on Linux.
I suspect other compilers might have the same problem.
--
Bjorn Munch Sun Microsystems
Trondheim, Norway http://sun.com/postgresql/
-------------- next part --------------
diff -c -r libpqxx/test/test_helpers.hxx bldtst/test/test_helpers.hxx
*** libpqxx/test/test_helpers.hxx Tue Aug 19 00:05:55 2008
--- bldtst/test/test_helpers.hxx Mon Aug 18 16:02:19 2008
***************
*** 175,181 ****
#define PQXX_REGISTER_TEST_CT(function, connection_type, transaction_type) \
namespace \
{ \
! pqxx::test::test_case<connection_type, transaction_type> \
test(#function, function); \
}
--- 175,181 ----
#define PQXX_REGISTER_TEST_CT(function, connection_type, transaction_type) \
namespace \
{ \
! pqxx::test::test_case<connection_type, transaction_type > \
test(#function, function); \
}
More information about the Libpqxx-general
mailing list