From 3ae1f7b11a7b5d92f945369adb4b458b451c27f0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 9 Nov 2015 18:08:46 +0200 Subject: Add bug: position pragmas don't work in macros --- bug/list | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'bug/list') diff --git a/bug/list b/bug/list index b9d28ac..4c62aeb 100644 --- a/bug/list +++ b/bug/list @@ -48,3 +48,40 @@ odb: error: unable to extract profile paths See email from /23-Oct-2014. + +- Position pragmas in macros don't work + + #include + + #define ODB_COUNT(obj, key) \ + PRAGMA_DB(view object(obj)) \ + struct obj##_count \ + { \ + PRAGMA_DB(column("count(" + obj::key + ")")) \ + int count; \ + }; + + /* + #define ODB_COUNT(obj, key) \ + struct obj##_count \ + { \ + int count; \ + }; \ + PRAGMA_DB(view(obj##_count) object(obj)) \ + PRAGMA_DB(member(obj##_count::count) \ + column("count(" + obj::key + ")")) \ + */ + + #pragma db object + struct test + { + #pragma db id + int id; + }; + + ODB_COUNT(test, id) + + The reason it doesn't work is because we use the macro expansion + point as the location of the pragmas inside the macro. Fixing this + properly won't be simple. Perhaps simply document as a limitation + where we describe PRAGMA_DB. -- cgit v1.1