Core Server
  1. Core Server
  2. SERVER-289

don't pollute global namespaces ( WAS: Mongo #assert squashes other asserts)

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major - P3 Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5.1
    • Component/s: C++ Driver
    • Labels:
      None
    • # Replies:
      4
    • Last comment by Customer:
      false

      Description

      When you try to assert something in a file which includes dbclient.h, the mongo assert replaces other asserts which may have been declared.

      EXAMPLE:

      foo.cc:
      #include <cassert>
      #include <mongo/client/dbclient.h>

      int main()

      { assert(false); }

      YIELDS:

      > g++ foo.cc -o foo
      foo.cc: In function 'int main()':
      foo.cc:5: error: 'asserted' was not declared in this scope

        Activity

        Hide
        Eliot Horowitz
        added a comment -

        made it compile at least - still squases, just uses mongo::asserted

        Show
        Eliot Horowitz
        added a comment - made it compile at least - still squases, just uses mongo::asserted
        Hide
        metagoto
        added a comment -

        I did a quick fix: moving 'using namespace' directives inside the mongo ns declaration in stdafx.h.
        Also needed: add the 2 directives in shell/dbshell.cpp (which is not in the mongo ns)
        I also had to qualify a few shared_ptr with boost:: in util/log.h

        The client part is 'fixed': i can build my project which depends on libmongoclient without names conflicts (even with -std=c++0x)

        My commit is
        http://github.com/metagoto/mongo/commit/dbfcac22a173e22b39921017dc4c7ce85016796a

        My master branch is up to date at that time. mongo server, tools, shell and lib compile with both sm and v8 on osx

        Show
        metagoto
        added a comment - I did a quick fix: moving 'using namespace' directives inside the mongo ns declaration in stdafx.h. Also needed: add the 2 directives in shell/dbshell.cpp (which is not in the mongo ns) I also had to qualify a few shared_ptr with boost:: in util/log.h The client part is 'fixed': i can build my project which depends on libmongoclient without names conflicts (even with -std=c++0x) My commit is http://github.com/metagoto/mongo/commit/dbfcac22a173e22b39921017dc4c7ce85016796a My master branch is up to date at that time. mongo server, tools, shell and lib compile with both sm and v8 on osx
        Hide
        Eliot Horowitz
        added a comment -

        merged that patch

        Show
        Eliot Horowitz
        added a comment - merged that patch
        Hide
        Mathias Stearn
        added a comment -

        fixed with http://github.com/mongodb/mongo/commit/60002a474169de84eac6bce20836ee553abf731c

        If you include mongo/client/cleanup.h it will remove our global macros.

        Show
        Mathias Stearn
        added a comment - fixed with http://github.com/mongodb/mongo/commit/60002a474169de84eac6bce20836ee553abf731c If you include mongo/client/cleanup.h it will remove our global macros.

          People

          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since reply:
              3 years, 51 weeks, 4 days ago
              Date of 1st Reply: