[SERVER-4594] syntax error in bsonobjbuilder.h Created: 02/Jan/12  Updated: 03/Jan/12  Resolved: 03/Jan/12

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.0.0, 2.0.1, 2.0.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Benedikt Böhm Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux 3.1.6 on x86_64, gcc version 4.5.3 (Gentoo 4.5.3-r1 p1.0, pie-0.4.5), manual compilation with no system libraries


Attachments: Text File 0001-do-not-clobber-L.patch    
Operating System: Linux
Participants:

 Description   

The following error is triggered when compiling the MongoDB backend for PowerDNS:

In file included from /usr/include/mongo/client/../util/../util/../db/jsobj.h:41:0,
                 from /usr/include/mongo/client/../util/../util/sock.h:25,
                 from /usr/include/mongo/client/../util/message.h:20,
                 from /usr/include/mongo/client/dbclient.h:24,
                 from mongodbbackend.hh:10,
                 from mongodbbackend.cc:18:
/usr/include/mongo/client/../util/../util/../db/../bson/bsonobjbuilder.h: At global scope:
/usr/include/mongo/client/../util/../util/../db/../bson/bsonobjbuilder.h:793:98: error: expected ',' or '...' before '&' token
/usr/include/mongo/client/../util/../util/../db/../bson/bsonobjbuilder.h: In function 'mongo::BSONObjBuilder& mongo::_appendIt(mongo::BSONObjBuilder&, const mongo::StringData&, const mongo::theL (*)())':
/usr/include/mongo/client/../util/../util/../db/../bson/bsonobjbuilder.h:796:23: error: expected nested-name-specifier before 'theL'
/usr/include/mongo/client/../util/../util/../db/../bson/bsonobjbuilder.h:796:23: error: expected '(' before 'theL'
/usr/include/mongo/client/../util/../util/../db/../bson/bsonobjbuilder.h:796:23: error: expected ';' before 'theL'
/usr/include/mongo/client/../util/../util/../db/../bson/bsonobjbuilder.h:796:59: error: 'i' was not declared in this scope
/usr/include/mongo/client/../util/../util/../db/../bson/bsonobjbuilder.h:796:64: error: 'vals' was not declared in this scope

i've bisected the code between 1.9.0 and 2.0.0 and found the following bad commit:

 
1cc69e30ad84a166ac1d48f68b20efa52c40fcc8 is the first bad commit
commit 1cc69e30ad84a166ac1d48f68b20efa52c40fcc8
Author: gregs <greg@10gen.com>
Date:   Fri Jun 3 17:58:26 2011 -0400
 
    be smarter about the pids we look for when cleaning old locks.

unfortunately my C++ skills are very weak and i've no idea what's going on



 Comments   
Comment by Eliot Horowitz (Inactive) [ 03/Jan/12 ]

Maks sense

Comment by Benedikt Böhm [ 03/Jan/12 ]

after a good night of sleep that's what i thought as well, and switching the order of headers indeed fixes the issue. d'oh

thanks for your help, you can close this issue.

Comment by Eliot Horowitz (Inactive) [ 03/Jan/12 ]

Can you undefine L before including the mongo headers or include them first?
If we apply this patch we could just break someone who has a LT define

Comment by Benedikt Böhm [ 02/Jan/12 ]

yes it is defined in http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/dns.hh#L268 and used all over the place for logging. was easier for me to change the template variable and left/right. i know it's not mongodbs fault, but it would be nice if you'd apply the patch

Comment by Eliot Horowitz (Inactive) [ 02/Jan/12 ]

Is the L it defines a macro?
If so - that should probably be changed.
Class template names shouldn't conflict with anything.

Comment by Benedikt Böhm [ 02/Jan/12 ]

i've finally found the issue: powerdns defines a global L for the logging object. i've attached a patch that renames the use of L in the header files.

Comment by Benedikt Böhm [ 02/Jan/12 ]

also the usage of L and R in bson-inl.h breaks:

/usr/include/mongo/client/../util/net/../../db/../bson/bson-inl.h: In function 'int mongo::compareElementValues(const mongo::BSONElement&, const mongo::BSONElement&)':
/usr/include/mongo/client/../util/net/../../db/../bson/bson-inl.h:69:27: warning: declaration of 'long long int mongo::theL()' has 'extern' and is initialized
/usr/include/mongo/client/../util/net/../../db/../bson/bson-inl.h:69:32: error: invalid pure specifier (only '= 0' is allowed) before '.' token
/usr/include/mongo/client/../util/net/../../db/../bson/bson-inl.h:69:45: error: function 'long long int mongo::theL()' is initialized like a variable
/usr/include/mongo/client/../util/net/../../db/../bson/bson-inl.h:78:21: warning: declaration of 'int mongo::theL()' has 'extern' and is initialized
/usr/include/mongo/client/../util/net/../../db/../bson/bson-inl.h:78:26: error: invalid pure specifier (only '= 0' is allowed) before '.' token
/usr/include/mongo/client/../util/net/../../db/../bson/bson-inl.h:78:38: error: function 'int mongo::theL()' is initialized like a variable

replacing L with left and R with right fixes this issue, and triggers another one:

mongodbbackend.hh: At global scope:
mongodbbackend.hh:109:5: error: 'auto_ptr' does not name a type

line 109 contains a simple auto_ptr<mongo::DBClientCursor> cursor;

source can be found at http://wiki.powerdns.com/trac/browser/trunk/pdns/modules/mongodbbackend/mongodbbackend.hh

Generated at Thu Feb 08 03:06:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.